diff --git a/templates/cli/index.js.twig b/templates/cli/index.js.twig index b3de4e6ef..1dc7761a6 100644 --- a/templates/cli/index.js.twig +++ b/templates/cli/index.js.twig @@ -32,8 +32,8 @@ program sortSubcommands: true }) .version(version, "-v, --version") - .option("--verbose", "Show complete error log") - .option("--json", "Output in JSON format") + .option("-V, --verbose", "Show complete error log") + .option("-j, --json", "Output in JSON format") .hook('preAction', migrate) .option("-f,--force", "Flag to confirm all warnings") .option("-a,--all", "Flag to push all resources") diff --git a/templates/cli/lib/commands/generic.js.twig b/templates/cli/lib/commands/generic.js.twig index 752a1aa23..1a258d664 100644 --- a/templates/cli/lib/commands/generic.js.twig +++ b/templates/cli/lib/commands/generic.js.twig @@ -3,7 +3,7 @@ const { Command } = require("commander"); const Client = require("../client"); const { sdkForConsole } = require("../sdks"); const { globalConfig, localConfig } = require("../config"); -const { actionRunner, success, parseBool, commandDescriptions, error, parse, log, drawTable } = require("../parser"); +const { actionRunner, success, parseBool, commandDescriptions, error, parse, log, drawTable, cliConfig } = require("../parser"); const ID = require("../id"); {% if sdk.test != "true" %} const { questionsLogin, questionsLogout, questionsListFactors, questionsMfaChallenge } = require("../questions"); @@ -90,8 +90,7 @@ const loginCommand = async ({ email, password, endpoint, mfa, code }) => { const whoami = new Command("whoami") .description(commandDescriptions['whoami']) - .option("-j, --json", "Output in JSON format") - .action(actionRunner(async ({ json }) => { + .action(actionRunner(async () => { if (globalConfig.getEndpoint() === '' || globalConfig.getCookie() === '') { error("No user is signed in. To sign in, run: appwrite login "); return; @@ -120,9 +119,9 @@ const whoami = new Command("whoami") 'Endpoint': globalConfig.getEndpoint() } ]; - if (json) { - console.log(data); + if(cliConfig.json) { + console.log(data); return; } @@ -204,12 +203,12 @@ const client = new Command("client") .configureHelp({ helpWidth: process.stdout.columns || 80 }) - .option("--selfSigned ", "Configure the CLI to use a self-signed certificate ( true or false )", parseBool) - .option("--endpoint ", "Set your Appwrite server endpoint") - .option("--projectId ", "Set your Appwrite project ID") - .option("--key ", "Set your Appwrite server's API key") - .option("--debug", "Print CLI debug information") - .option("--reset", "Reset the CLI configuration") + .option("-ss, --selfSigned ", "Configure the CLI to use a self-signed certificate ( true or false )", parseBool) + .option("-e, --endpoint ", "Set your Appwrite server endpoint") + .option("-p, --projectId ", "Set your Appwrite project ID") + .option("-k, --key ", "Set your Appwrite server's API key") + .option("-d, --debug", "Print CLI debug information") + .option("-r, --reset", "Reset the CLI configuration") .action(actionRunner(async ({ selfSigned, endpoint, projectId, key, debug, reset }, command) => { if (selfSigned == undefined && endpoint == undefined && projectId == undefined && key == undefined && debug == undefined && reset == undefined) { command.help() diff --git a/templates/cli/lib/commands/pull.js.twig b/templates/cli/lib/commands/pull.js.twig index 82a088cb9..c4f4fefe3 100644 --- a/templates/cli/lib/commands/pull.js.twig +++ b/templates/cli/lib/commands/pull.js.twig @@ -199,28 +199,33 @@ pull .action(actionRunner(pullProject)); pull - .command("functions") - .description(`Pull your {{ spec.title|caseUcfirst }} functions`) - .action(actionRunner(pullFunctions)); + .command("function") + .alias("functions") + .description("Pulling your {{ spec.title|caseUcfirst }} cloud function") + .action(actionRunner(pullFunction)) pull - .command("collections") - .description("Pull your {{ spec.title|caseUcfirst }} collections") + .command("collection") + .alias("collections") + .description("Pulling your {{ spec.title|caseUcfirst }} collections") .action(actionRunner(pullCollection)) pull - .command("buckets") - .description("Pull your {{ spec.title|caseUcfirst }} buckets") + .command("bucket") + .alias("buckets") + .description("Pulling your Appwrite buckets") .action(actionRunner(pullBucket)) pull - .command("teams") - .description("Pull your {{ spec.title|caseUcfirst }} teams") + .command("team") + .alias("teams") + .description("Pulling your Appwrite teams") .action(actionRunner(pullTeam)) pull - .command("topics") - .description("Pull your {{ spec.title|caseUcfirst }} messaging topics") + .command("topic") + .alias("topics") + .description("Initialise your Appwrite messaging topics") .action(actionRunner(pullMessagingTopic)) module.exports = { diff --git a/templates/cli/lib/commands/push.js.twig b/templates/cli/lib/commands/push.js.twig index ca0ca4cf9..a2672743f 100644 --- a/templates/cli/lib/commands/push.js.twig +++ b/templates/cli/lib/commands/push.js.twig @@ -1335,6 +1335,7 @@ const pushMessagingTopic = async ({ returnOnZero } = { returnOnZero: false }) => const push = new Command("push") .alias('deploy') .description(commandDescriptions['push']) + .action(actionRunner(pushResources)); push .command("all") @@ -1347,29 +1348,34 @@ push .action(actionRunner(pushProject)); push - .command("functions") + .command("function") + .alias("functions") .description("Push functions in the current directory.") - .option(`--functionId `, `Function ID`) - .option(`--async`, `Don't wait for functions deployments status`) + .option(`-f, --functionId `, `Function ID`) + .option(`-A, --async`, `Don't wait for functions deployments status`) .action(actionRunner(pushFunction)); push - .command("collections") + .command("collection") + .alias("collections") .description("Push collections in the current project.") .action(actionRunner(pushCollection)); push - .command("buckets") + .command("bucket") + .alias("buckets") .description("Push buckets in the current project.") .action(actionRunner(pushBucket)); push - .command("teams") + .command("team") + .alias("teams") .description("Push teams in the current project.") .action(actionRunner(pushTeam)); push - .command("topics") + .command("topic") + .alias("topics") .description("Push messaging topics in the current project.") .action(actionRunner(pushMessagingTopic));