Skip to content

🎥 Make videos programmatically with React

fig autocomplete

Jonny Burger9b0512a34ad8
diff --git a/packages/cli-autocomplete/src/source.ts b/packages/cli-autocomplete/src/source.ts
index ed4eb3bd4a..afb59ef206 100644
--- a/packages/cli-autocomplete/src/source.ts
+++ b/packages/cli-autocomplete/src/source.ts
@@ -1,6 +1,12 @@
+import {uniqueOptions} from './unique-options';
+
const alwaysOptions: Fig.Option[] = [
{
- name: ['--quiet', '-q'],
+ name: '--quiet',
+ description: 'Print less output',
+ },
+ {
+ name: '-q',
description: 'Print less output',
},
{
@@ -443,27 +449,29 @@ const globalLambdaOptions: Fig.Option[] = [
},
];
-const benchmarkOptions: Fig.Option[] = [
- ...renderOptions,
- ...localRenderOptions,
- ...localRenderAndStillOptions,
- ...alwaysOptions,
- {
- name: '--concurrencies',
- description:
- 'Comma-separated list of concurrency values to include in benchmark',
- },
-].filter((b) => {
- if (b.name === '--overwrite') {
- return false;
- }
+const benchmarkOptions: Fig.Option[] = uniqueOptions(
+ [
+ ...renderOptions,
+ ...localRenderOptions,
+ ...localRenderAndStillOptions,
+ ...alwaysOptions,
+ {
+ name: '--concurrencies',
+ description:
+ 'Comma-separated list of concurrency values to include in benchmark',
+ },
+ ].filter((b) => {
+ if (b.name === '--overwrite') {
+ return false;
+ }
- if (b.name === '--concurrency') {
- return false;
- }
+ if (b.name === '--concurrency') {
+ return false;
+ }
- return true;
-});
+ return true;
+ })
+);
const completionSpec: Fig.Spec = {
name: 'remotion',
@@ -566,13 +574,13 @@ const completionSpec: Fig.Spec = {
isOptional: true,
},
],
- options: [
+ options: uniqueOptions([
...lambdaRenderAndStillOptions,
...lambdaRenderOptions,
...renderOptions,
...globalLambdaOptions,
...alwaysOptions,
- ],
+ ]),
},
{
name: 'compositions',
@@ -626,12 +634,12 @@ const completionSpec: Fig.Spec = {
],
},
],
- options: [
+ options: uniqueOptions([
...lambdaRenderAndStillOptions,
...stillOptions,
...globalLambdaOptions,
...alwaysOptions,
- ],
+ ]),
},
{
name: 'functions',
@@ -800,12 +808,12 @@ const completionSpec: Fig.Spec = {
isOptional: true,
},
],
- options: [
+ options: uniqueOptions([
...renderOptions,
...localRenderOptions,
...localRenderAndStillOptions,
...alwaysOptions,
- ],
+ ]),
},
{
name: 'still',
diff --git a/packages/cli-autocomplete/src/unique-options.ts b/packages/cli-autocomplete/src/unique-options.ts
new file mode 100644
index 0000000000..6b9ef0310f
--- /dev/null
+++ b/packages/cli-autocomplete/src/unique-options.ts
@@ -0,0 +1,17 @@
+// eslint-disable-next-line @withfig/fig-linter/no-missing-default-export
+export const uniqueOptions = (options: Fig.Option[]) => {
+ const seenOptions: Record<string, Fig.Option> = {};
+ const uniqueOptions: Fig.Option[] = [];
+
+ for (const option of options) {
+ if (typeof option.name !== 'string') {
+ throw new Error('this script does not support arrays of options');
+ }
+ if (!seenOptions[option.name]) {
+ seenOptions[option.name] = option;
+ uniqueOptions.push(option);
+ }
+ }
+
+ return uniqueOptions;
+};