Skip to content

🎥 Make videos programmatically with React

Support command paths after remotion help

JonnyBurgerc3659f693de8
diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts
index 8771cfadd5..8cbb3f9fcb 100644
--- a/packages/cli/src/index.ts
+++ b/packages/cli/src/index.ts
@@ -59,19 +59,24 @@ const {packageManagerOption, skipSkillsOption, versionFlagOption} =
export const cli = async () => {
const [command, ...args] = parsedCli._;
- if (parsedCli.help) {
- if (command === 'lambda' || command === 'cloudrun') {
+ const helpPath =
+ command === 'help' && (args.length > 0 || !parsedCli.help)
+ ? args
+ : parsedCli._;
+ if (parsedCli.help || command === 'help') {
+ const [helpCommand, ...helpArgs] = helpPath;
+ if (helpCommand === 'lambda' || helpCommand === 'cloudrun') {
const helpRemotionRoot = RenderInternals.findRemotionRoot();
const printed =
- command === 'lambda'
- ? tryPrintLambdaHelp(helpRemotionRoot, args, 'info')
- : tryPrintCloudrunHelp(helpRemotionRoot, args, 'info');
+ helpCommand === 'lambda'
+ ? tryPrintLambdaHelp(helpRemotionRoot, helpArgs, 'info')
+ : tryPrintCloudrunHelp(helpRemotionRoot, helpArgs, 'info');
if (printed) {
return;
}
}
- printHelp('info', parsedCli._);
+ printHelp('info', helpPath);
return;
}
@@ -176,9 +181,6 @@ export const cli = async () => {
await browserCommand(args, logLevel);
} else if (command === 'benchmark') {
await benchmarkCommand(remotionRoot, args, logLevel);
- } else if (command === 'help') {
- printHelp(logLevel, []);
- process.exit(0);
} else {
if (command) {
Log.error({indent: false, logLevel}, `Command ${command} not found.`);
diff --git a/packages/cli/src/test/help.test.ts b/packages/cli/src/test/help.test.ts
index 1635b8be85..26bcf09d01 100644
--- a/packages/cli/src/test/help.test.ts
+++ b/packages/cli/src/test/help.test.ts
@@ -100,50 +100,81 @@ test('prints command-specific help without running the command', () => {
options,
excludedOptions = [],
} of commandHelpPages) {
- const result = spawnSync(
- 'node',
- [cliPath, ...args, '--help', '--log=error'],
- {
- cwd: temporaryDirectory,
- encoding: 'utf8',
- env: childEnvironment,
- stdio: ['ignore', 'pipe', 'pipe'],
- timeout: 10_000,
- },
- );
+ for (const invocation of [
+ [...args, '--help'],
+ ['help', ...args],
+ ]) {
+ const result = spawnSync(
+ 'node',
+ [cliPath, ...invocation, '--log=error'],
+ {
+ cwd: temporaryDirectory,
+ encoding: 'utf8',
+ env: childEnvironment,
+ stdio: ['ignore', 'pipe', 'pipe'],
+ timeout: 10_000,
+ },
+ );
- if (result.error) {
- throw result.error;
- }
+ if (result.error) {
+ throw result.error;
+ }
- expect(result.signal).toBeNull();
- expect(result.status).toBe(0);
- expect(result.stderr).toBe('');
- expect(result.stdout).toContain(`remotion ${args.join(' ')}`);
- expect(result.stdout).toContain(
- `https://www.remotion.dev${documentation}`,
- );
- expect(result.stdout).not.toContain('Available commands:');
- expect(result.stdout).toContain('Options:');
- for (const option of ['--help', ...options]) {
- const optionLine = result.stdout.split('\n').find((line) => {
- const trimmed = line.trimStart();
- return (
- trimmed.startsWith(`${option} `) || trimmed.startsWith(`${option},`)
- );
- });
- if (!optionLine) {
- throw new Error(
- `Expected \`remotion ${args.join(' ')} --help\` to document ${option}`,
- );
+ expect(result.signal).toBeNull();
+ expect(result.status).toBe(0);
+ expect(result.stderr).toBe('');
+ expect(result.stdout).toContain(`remotion ${args.join(' ')}`);
+ expect(result.stdout).toContain(
+ `https://www.remotion.dev${documentation}`,
+ );
+ expect(result.stdout).not.toContain('Available commands:');
+ expect(result.stdout).toContain('Options:');
+ for (const option of ['--help', ...options]) {
+ const optionLine = result.stdout.split('\n').find((line) => {
+ const trimmed = line.trimStart();
+ return (
+ trimmed.startsWith(`${option} `) ||
+ trimmed.startsWith(`${option},`)
+ );
+ });
+ if (!optionLine) {
+ throw new Error(
+ `Expected \`remotion ${invocation.join(' ')}\` to document ${option}`,
+ );
+ }
}
- }
- for (const option of excludedOptions) {
- expect(result.stdout).not.toContain(option);
+ for (const option of excludedOptions) {
+ expect(result.stdout).not.toContain(option);
+ }
}
}
+ const helpCommandResult = spawnSync(
+ 'node',
+ [cliPath, 'help', '--log=error'],
+ {
+ cwd: temporaryDirectory,
+ encoding: 'utf8',
+ env: childEnvironment,
+ stdio: ['ignore', 'pipe', 'pipe'],
+ timeout: 10_000,
+ },
+ );
+
+ if (helpCommandResult.error) {
+ throw helpCommandResult.error;
+ }
+
+ expect(helpCommandResult.signal).toBeNull();
+ expect(helpCommandResult.status).toBe(0);
+ expect(helpCommandResult.stderr).toBe('');
+ expect(helpCommandResult.stdout).toContain('Available commands:');
+ expect(helpCommandResult.stdout).toContain('remotion render');
+ expect(helpCommandResult.stdout).toContain(
+ 'https://www.remotion.dev/docs/cli',
+ );
+
expect(readdirSync(temporaryDirectory)).toEqual(initialFiles);
} finally {
rmSync(temporaryDirectory, {recursive: true, force: true});
diff --git a/packages/cloudrun/src/test/cli-help.test.ts b/packages/cloudrun/src/test/cli-help.test.ts
index 1d4e42c795..4fc4fa000f 100644
--- a/packages/cloudrun/src/test/cli-help.test.ts
+++ b/packages/cloudrun/src/test/cli-help.test.ts
@@ -123,38 +123,42 @@ test('the Remotion CLI delegates Cloud Run help before loading config', () => {
delete childEnvironment.FORCE_COLOR;
try {
- const result = spawnSync(
- 'node',
- [
- path.join(exampleDirectory, '..', 'cli', 'remotion-cli.js'),
- 'cloudrun',
- 'render',
- '--help',
- '--log=error',
- ],
- {
- cwd: temporaryDirectory,
- encoding: 'utf8',
- env: childEnvironment,
- stdio: ['ignore', 'pipe', 'pipe'],
- timeout: 10_000,
- },
- );
+ for (const invocation of [
+ ['cloudrun', 'render', '--help'],
+ ['help', 'cloudrun', 'render'],
+ ]) {
+ const result = spawnSync(
+ 'node',
+ [
+ path.join(exampleDirectory, '..', 'cli', 'remotion-cli.js'),
+ ...invocation,
+ '--log=error',
+ ],
+ {
+ cwd: temporaryDirectory,
+ encoding: 'utf8',
+ env: childEnvironment,
+ stdio: ['ignore', 'pipe', 'pipe'],
+ timeout: 10_000,
+ },
+ );
- if (result.error) {
- throw result.error;
+ if (result.error) {
+ throw result.error;
+ }
+
+ expect(result.signal).toBeNull();
+ expect(result.status).toBe(0);
+ expect(result.stderr).toBe('');
+ expect(result.stdout).toStartWith('remotion cloudrun render ');
+ expect(result.stdout).not.toContain('©');
+ expect(result.stdout).toContain('remotion cloudrun render');
+ expect(result.stdout).toContain('--service-name <service-name>');
+ expect(result.stdout).toContain(
+ 'https://www.remotion.dev/docs/cloudrun/cli/render',
+ );
}
- expect(result.signal).toBeNull();
- expect(result.status).toBe(0);
- expect(result.stderr).toBe('');
- expect(result.stdout).toStartWith('remotion cloudrun render ');
- expect(result.stdout).not.toContain('©');
- expect(result.stdout).toContain('remotion cloudrun render');
- expect(result.stdout).toContain('--service-name <service-name>');
- expect(result.stdout).toContain(
- 'https://www.remotion.dev/docs/cloudrun/cli/render',
- );
expect(readdirSync(temporaryDirectory)).toEqual(initialFiles);
} finally {
rmSync(temporaryDirectory, {recursive: true, force: true});
diff --git a/packages/lambda/src/test/unit/cli-help.test.ts b/packages/lambda/src/test/unit/cli-help.test.ts
index 8eacac02af..d7399ac1a8 100644
--- a/packages/lambda/src/test/unit/cli-help.test.ts
+++ b/packages/lambda/src/test/unit/cli-help.test.ts
@@ -176,38 +176,42 @@ test('the Remotion CLI delegates Lambda help before loading config', () => {
delete childEnvironment.FORCE_COLOR;
try {
- const result = spawnSync(
- 'node',
- [
- path.join(exampleDirectory, '..', 'cli', 'remotion-cli.js'),
- 'lambda',
- 'render',
- '--help',
- '--log=error',
- ],
- {
- cwd: temporaryDirectory,
- encoding: 'utf8',
- env: childEnvironment,
- stdio: ['ignore', 'pipe', 'pipe'],
- timeout: 10_000,
- },
- );
-
- if (result.error) {
- throw result.error;
+ for (const invocation of [
+ ['lambda', 'render', '--help'],
+ ['help', 'lambda', 'render'],
+ ]) {
+ const result = spawnSync(
+ 'node',
+ [
+ path.join(exampleDirectory, '..', 'cli', 'remotion-cli.js'),
+ ...invocation,
+ '--log=error',
+ ],
+ {
+ cwd: temporaryDirectory,
+ encoding: 'utf8',
+ env: childEnvironment,
+ stdio: ['ignore', 'pipe', 'pipe'],
+ timeout: 10_000,
+ },
+ );
+
+ if (result.error) {
+ throw result.error;
+ }
+
+ expect(result.signal).toBeNull();
+ expect(result.status).toBe(0);
+ expect(result.stderr).toBe('');
+ expect(result.stdout).toStartWith('remotion lambda render ');
+ expect(result.stdout).not.toContain('©');
+ expect(result.stdout).toContain('remotion lambda render');
+ expect(result.stdout).toContain('--frames-per-lambda <count>');
+ expect(result.stdout).toContain(
+ 'https://www.remotion.dev/docs/lambda/cli/render',
+ );
}
- expect(result.signal).toBeNull();
- expect(result.status).toBe(0);
- expect(result.stderr).toBe('');
- expect(result.stdout).toStartWith('remotion lambda render ');
- expect(result.stdout).not.toContain('©');
- expect(result.stdout).toContain('remotion lambda render');
- expect(result.stdout).toContain('--frames-per-lambda <count>');
- expect(result.stdout).toContain(
- 'https://www.remotion.dev/docs/lambda/cli/render',
- );
expect(readdirSync(temporaryDirectory)).toEqual(initialFiles);
} finally {
rmSync(temporaryDirectory, {recursive: true, force: true});