🎥 Make videos programmatically with React
CLI help flag
Jonny Burger56e7ccbe4dd4
diff --git a/packages/cli/src/index.tsx b/packages/cli/src/index.tsxindex 391c125c7b..8cf39955d0 100644--- a/packages/cli/src/index.tsx+++ b/packages/cli/src/index.tsx@@ -3,13 +3,20 @@import xns from 'xns';import {checkNodeVersion} from './check-version';import {Log} from './log';+import {parsedCli} from './parse-command-line';import {previewCommand} from './preview';+import {printHelp} from './print-help';import {render} from './render';import {upgrade} from './upgrade';export const cli = xns(async () => {const args = process.argv;const command = args[2];++ if (parsedCli.help) {+ printHelp();+ process.exit(0);+ }//To check node version and to warn if node version is <12.10.0checkNodeVersion();@@ -21,10 +28,7 @@ export const cli = xns(async () => {await upgrade();} else {Log.Error(`Command ${command} not found.`);- Log.Info('Available commands:');- Log.Info(' preview');- Log.Info(' render');- Log.Info(' upgrade');+ printHelp();process.exit(1);}});diff --git a/packages/cli/src/parse-command-line.ts b/packages/cli/src/parse-command-line.tsindex 02c3046156..c14d1c454e 100644--- a/packages/cli/src/parse-command-line.ts+++ b/packages/cli/src/parse-command-line.ts@@ -27,6 +27,7 @@ export type CommandLineOptions = {frames: string | number;sequence: boolean;log: string;+ help: boolean;};export const parsedCli = minimist<CommandLineOptions>(process.argv.slice(2));diff --git a/packages/cli/src/print-help.ts b/packages/cli/src/print-help.tsnew file mode 100644index 0000000000..062bcb28c9--- /dev/null+++ b/packages/cli/src/print-help.ts@@ -0,0 +1,50 @@+import chalk from 'chalk';+import {Log} from './log';++const packagejson = require('../package.json');++const printFlags = (flags: [string, string][]) => {+ flags.forEach(([flag, description]) => {+ Log.Info(chalk.blue(`${flag.padEnd(22, ' ')} ${description}`));+ });+};++export const printHelp = () => {+ Log.Info(+ `@remotion/cli ${+ packagejson.version+ } © ${new Date().getFullYear()} Jonny Burger`+ );+ Log.Info();+ Log.Info('Available commands:');+ Log.Info('');+ Log.Info('remotion preview <index-file.ts>');+ Log.Info(chalk.gray('Start the preview server.'));+ printFlags([['--props', 'Pass input props as filename or as JSON']]);+ Log.Info();+ Log.Info('remotion render <index-file.ts> <comp-name> <output-file.mp4>');+ Log.Info(chalk.gray('Render video, audio or an image sequence.'));+ printFlags([+ ['--props', 'Pass input props as filename or as JSON'],+ ['--concurrency', 'How many frames to render in parallel'],+ ['--image-format', 'Format to render the frames in, "jpeg" or "png"'],+ ['--pixel-format', 'Custom pixel format, see docs for available values'],+ ['--config', 'Custom location for a Remotion config file'],+ ['--quality', 'Quality for rendered frames, JPEG only, 0-100'],+ ['--overwrite', 'Overwrite if file exists, default true'],+ ['--sequence', 'Output as an image sequence'],+ ['--codec', 'Video of audio codec'],+ ['--crf', 'FFMPEG CRF value, controls quality, see docs for info'],+ ['--browser-executable', 'Custom path for browser executable'],+ ['--frames', 'Render a portion or a still of a video'],+ ['--bundle-cache', 'Cache webpack bundle, boolean, default true'],+ ['--log', 'Log level, "error", "warning", "verbose", "info" (default)'],+ ]);+ Log.Info();+ Log.Info('remotion upgrade');+ Log.Info(chalk.gray('Ensure Remotion is on the newest version.'));+ Log.Info();+ Log.Info(+ 'Visit https://www.remotion.dev/docs/cli for browsable CLI documentation.'+ );+};