🎥 Make videos programmatically with React
simplify CLI parsing mechanism
Jonny Burger50071ca009e1
diff --git a/packages/cli/src/initialize-render-cli.ts b/packages/cli/src/initialize-render-cli.tsindex 212f6c6841..5d4b40bf51 100644--- a/packages/cli/src/initialize-render-cli.ts+++ b/packages/cli/src/initialize-render-cli.ts@@ -2,13 +2,10 @@ import {loadConfig} from './get-config-file-name';import {Log} from './log';import {parseCommandLine} from './parse-command-line';-export const initializeRenderCli = async (- remotionRoot: string,- type: 'still' | 'sequence' | 'lambda' | 'preview'-) => {+export const initializeRenderCli = async (remotionRoot: string) => {const appliedName = await loadConfig(remotionRoot);- parseCommandLine(type);+ parseCommandLine();// Only now Log.verbose is availableLog.verbose('Remotion root directory:', remotionRoot);diff --git a/packages/cli/src/lambda-command.ts b/packages/cli/src/lambda-command.tsindex 1c7183147f..4d1c8f0726 100644--- a/packages/cli/src/lambda-command.ts+++ b/packages/cli/src/lambda-command.ts@@ -10,7 +10,7 @@ export const lambdaCommand = async (remotionRoot: string) => {paths: [remotionRoot],});const {LambdaInternals} = require(path);- await initializeRenderCli(remotionRoot, 'lambda');+ await initializeRenderCli(remotionRoot);await LambdaInternals.executeCommand(parsedCli._.slice(1));process.exit(0);diff --git a/packages/cli/src/parse-command-line.ts b/packages/cli/src/parse-command-line.tsindex 7f74454396..40339b8246 100644--- a/packages/cli/src/parse-command-line.ts+++ b/packages/cli/src/parse-command-line.ts@@ -80,9 +80,7 @@ export const parsedCli = minimist<CommandLineOptions>(process.argv.slice(2), {boolean: BooleanFlags,});-export const parseCommandLine = (- type: 'still' | 'sequence' | 'lambda' | 'preview' | 'versions'-) => {+export const parseCommandLine = () => {if (parsedCli['pixel-format']) {Config.Output.setPixelFormat(parsedCli['pixel-format']);}@@ -150,24 +148,10 @@ export const parseCommandLine = (}if (parsedCli.frames) {- if (type === 'still') {- Log.error(- '--frames flag was passed to the `still` command. This flag only works with the `render` command. Did you mean `--frame`? See reference: https://www.remotion.dev/docs/cli/'- );- process.exit(1);- }-ConfigInternals.setFrameRangeFromCli(parsedCli.frames);}if (parsedCli.frame) {- if (type === 'sequence') {- Log.error(- '--frame flag was passed to the `render` command. This flag only works with the `still` command. Did you mean `--frames`? See reference: https://www.remotion.dev/docs/cli/'- );- process.exit(1);- }-ConfigInternals.setStillFrame(Number(parsedCli.frame));}diff --git a/packages/cli/src/preview.ts b/packages/cli/src/preview.tsindex 843257fdf3..2ad14808e7 100644--- a/packages/cli/src/preview.ts+++ b/packages/cli/src/preview.ts@@ -49,7 +49,7 @@ export const previewCommand = async (remotionRoot: string) => {const {port: desiredPort} = parsedCli;const fullPath = path.join(process.cwd(), file);- await initializeRenderCli(remotionRoot, 'preview');+ await initializeRenderCli(remotionRoot);let inputProps = getInputProps((newProps) => {waitForLiveEventsListener().then((listener) => {diff --git a/packages/cli/src/render.tsx b/packages/cli/src/render.tsxindex 26532d8374..8ab42d290e 100644--- a/packages/cli/src/render.tsx+++ b/packages/cli/src/render.tsx@@ -49,7 +49,14 @@ export const render = async (remotionRoot: string) => {const downloadMap = RenderInternals.makeDownloadMap();- await initializeRenderCli(remotionRoot, 'sequence');+ if (parsedCli.frame) {+ Log.error(+ '--frame flag was passed to the `render` command. This flag only works with the `still` command. Did you mean `--frames`? See reference: https://www.remotion.dev/docs/cli/'+ );+ process.exit(1);+ }++ await initializeRenderCli(remotionRoot);Log.verbose('Asset dirs', downloadMap.assetDir);diff --git a/packages/cli/src/still.ts b/packages/cli/src/still.tsindex 6c08505ea9..d939e874bd 100644--- a/packages/cli/src/still.ts+++ b/packages/cli/src/still.ts@@ -37,7 +37,14 @@ export const still = async (remotionRoot: string) => {? file: path.join(process.cwd(), file);- await initializeRenderCli(remotionRoot, 'still');+ if (parsedCli.frames) {+ Log.error(+ '--frames flag was passed to the `still` command. This flag only works with the `render` command. Did you mean `--frame`? See reference: https://www.remotion.dev/docs/cli/'+ );+ process.exit(1);+ }++ await initializeRenderCli(remotionRoot);const userPassedOutput = getUserPassedOutputLocation();if (diff --git a/packages/cli/src/versions.ts b/packages/cli/src/versions.tsindex eeba09f2ec..43a61f3ba2 100644--- a/packages/cli/src/versions.ts+++ b/packages/cli/src/versions.ts@@ -97,7 +97,7 @@ export const validateVersionsBeforeCommand = async (remotionRoot: string) => {};export const versionsCommand = async (remotionRoot: string) => {- parseCommandLine('versions');+ parseCommandLine();const versions = await getAllVersions(remotionRoot);const grouped = groupBy(versions);