Skip to content

🎥 Make videos programmatically with React

ls subcommand

Jonny Burgerc3006c0cf56c
diff --git a/packages/lambda/src/cli/commands/functions/index.ts b/packages/lambda/src/cli/commands/functions/index.ts
new file mode 100644
index 0000000000..a21f479fff
--- /dev/null
+++ b/packages/lambda/src/cli/commands/functions/index.ts
@@ -0,0 +1,29 @@
+import {CliInternals} from '@remotion/cli';
+import {Log} from '@remotion/cli/dist/log';
+import {BINARY_NAME} from '../../../shared/constants';
+import {functionsLsCommand, FUNCTIONS_LS_SUBCOMMAND} from './ls';
+
+export const FUNCTIONS_COMMAND = 'functions';
+
+const printFunctionsHelp = () => {
+ Log.info(`${BINARY_NAME} ${FUNCTIONS_COMMAND} <subcommand>`);
+ Log.info();
+ Log.info('Available subcommands:');
+ Log.info('');
+ Log.info(`${BINARY_NAME} ${FUNCTIONS_COMMAND} ${FUNCTIONS_LS_SUBCOMMAND}`);
+ Log.info(CliInternals.chalk.gray('Lists the functions currently deployed'));
+};
+
+export const functionsCommand = (args: string[]) => {
+ if (args[0] === FUNCTIONS_LS_SUBCOMMAND) {
+ return functionsLsCommand();
+ }
+
+ if (args[0]) {
+ Log.error(`Subcommand ${args[0]} not found.`);
+ printFunctionsHelp();
+ process.exit(1);
+ }
+
+ printFunctionsHelp();
+};
diff --git a/packages/lambda/src/cli/functions.ts b/packages/lambda/src/cli/commands/functions/ls.ts
similarity index 81%
rename from packages/lambda/src/cli/functions.ts
rename to packages/lambda/src/cli/commands/functions/ls.ts
index 3df300d5d5..b2e9b7d7d9 100644
--- a/packages/lambda/src/cli/functions.ts
+++ b/packages/lambda/src/cli/commands/functions/ls.ts
@@ -1,17 +1,17 @@
import {CliInternals} from '@remotion/cli';
import {Log} from '@remotion/cli/dist/log';
-import {getDeployedLambdas} from '../api/get-deployed-lambdas';
-import {getFunctionVersion} from '../api/get-function-version';
-import {getAwsRegion} from './get-aws-region';
-
-export const FUNCTIONS_COMMAND = 'functions';
+import {getDeployedLambdas} from '../../../api/get-deployed-lambdas';
+import {getFunctionVersion} from '../../../api/get-function-version';
+import {getAwsRegion} from '../../get-aws-region';
const NAME_COLS = 32;
const MEMORY_COLS = 15;
const TIMEOUT_COLS = 15;
const VERSION_COLS = 15;
-export const functionsCommand = async () => {
+export const FUNCTIONS_LS_SUBCOMMAND = 'ls';
+
+export const functionsLsCommand = async () => {
const region = getAwsRegion();
const functions = await getDeployedLambdas({
region,
diff --git a/packages/lambda/src/cli/index.ts b/packages/lambda/src/cli/index.ts
index e3b65a386e..6aacd11787 100644
--- a/packages/lambda/src/cli/index.ts
+++ b/packages/lambda/src/cli/index.ts
@@ -1,8 +1,8 @@
import {CliInternals} from '@remotion/cli';
import {parsedLambdaCli} from './args';
import {cleanupCommand, CLEANUP_COMMAND} from './cleanup';
+import {functionsCommand, FUNCTIONS_COMMAND} from './commands/functions';
import {deployCommand, DEPLOY_COMMAND} from './deploy';
-import {functionsCommand, FUNCTIONS_COMMAND} from './functions';
import {printHelp} from './help';
import {Log} from './log';
import {policiesCommand, POLICIES_COMMAND} from './policies';
@@ -28,7 +28,7 @@ const matchCommand = async () => {
}
if (parsedLambdaCli._[0] === FUNCTIONS_COMMAND) {
- return functionsCommand();
+ return functionsCommand(parsedLambdaCli._.slice(1));
}
if (parsedLambdaCli._[0] === CLEANUP_COMMAND) {