Skip to content

Commit 8abc65a

Browse files
Merge pull request #858 from appwrite/fix-cli-aliases
Fix: Improve CLI aliases
2 parents 2014675 + c1e497d commit 8abc65a

File tree

4 files changed

+41
-31
lines changed

4 files changed

+41
-31
lines changed

templates/cli/index.js.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@ program
3232
sortSubcommands: true
3333
})
3434
.version(version, "-v, --version")
35-
.option("--verbose", "Show complete error log")
36-
.option("--json", "Output in JSON format")
35+
.option("-V, --verbose", "Show complete error log")
36+
.option("-j, --json", "Output in JSON format")
3737
.hook('preAction', migrate)
3838
.option("-f,--force", "Flag to confirm all warnings")
3939
.option("-a,--all", "Flag to push all resources")

templates/cli/lib/commands/generic.js.twig

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const { Command } = require("commander");
33
const Client = require("../client");
44
const { sdkForConsole } = require("../sdks");
55
const { globalConfig, localConfig } = require("../config");
6-
const { actionRunner, success, parseBool, commandDescriptions, error, parse, log, drawTable } = require("../parser");
6+
const { actionRunner, success, parseBool, commandDescriptions, error, parse, log, drawTable, cliConfig } = require("../parser");
77
const ID = require("../id");
88
{% if sdk.test != "true" %}
99
const { questionsLogin, questionsLogout, questionsListFactors, questionsMfaChallenge } = require("../questions");
@@ -90,8 +90,7 @@ const loginCommand = async ({ email, password, endpoint, mfa, code }) => {
9090

9191
const whoami = new Command("whoami")
9292
.description(commandDescriptions['whoami'])
93-
.option("-j, --json", "Output in JSON format")
94-
.action(actionRunner(async ({ json }) => {
93+
.action(actionRunner(async () => {
9594
if (globalConfig.getEndpoint() === '' || globalConfig.getCookie() === '') {
9695
error("No user is signed in. To sign in, run: appwrite login ");
9796
return;
@@ -120,9 +119,9 @@ const whoami = new Command("whoami")
120119
'Endpoint': globalConfig.getEndpoint()
121120
}
122121
];
123-
if (json) {
124-
console.log(data);
125122

123+
if(cliConfig.json) {
124+
console.log(data);
126125
return;
127126
}
128127

@@ -204,12 +203,12 @@ const client = new Command("client")
204203
.configureHelp({
205204
helpWidth: process.stdout.columns || 80
206205
})
207-
.option("--selfSigned <value>", "Configure the CLI to use a self-signed certificate ( true or false )", parseBool)
208-
.option("--endpoint <endpoint>", "Set your Appwrite server endpoint")
209-
.option("--projectId <projectId>", "Set your Appwrite project ID")
210-
.option("--key <key>", "Set your Appwrite server's API key")
211-
.option("--debug", "Print CLI debug information")
212-
.option("--reset", "Reset the CLI configuration")
206+
.option("-ss, --selfSigned <value>", "Configure the CLI to use a self-signed certificate ( true or false )", parseBool)
207+
.option("-e, --endpoint <endpoint>", "Set your Appwrite server endpoint")
208+
.option("-p, --projectId <projectId>", "Set your Appwrite project ID")
209+
.option("-k, --key <key>", "Set your Appwrite server's API key")
210+
.option("-d, --debug", "Print CLI debug information")
211+
.option("-r, --reset", "Reset the CLI configuration")
213212
.action(actionRunner(async ({ selfSigned, endpoint, projectId, key, debug, reset }, command) => {
214213
if (selfSigned == undefined && endpoint == undefined && projectId == undefined && key == undefined && debug == undefined && reset == undefined) {
215214
command.help()

templates/cli/lib/commands/pull.js.twig

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -199,28 +199,33 @@ pull
199199
.action(actionRunner(pullProject));
200200

201201
pull
202-
.command("functions")
203-
.description(`Pull your {{ spec.title|caseUcfirst }} functions`)
204-
.action(actionRunner(pullFunctions));
202+
.command("function")
203+
.alias("functions")
204+
.description("Pulling your {{ spec.title|caseUcfirst }} cloud function")
205+
.action(actionRunner(pullFunction))
205206

206207
pull
207-
.command("collections")
208-
.description("Pull your {{ spec.title|caseUcfirst }} collections")
208+
.command("collection")
209+
.alias("collections")
210+
.description("Pulling your {{ spec.title|caseUcfirst }} collections")
209211
.action(actionRunner(pullCollection))
210212

211213
pull
212-
.command("buckets")
213-
.description("Pull your {{ spec.title|caseUcfirst }} buckets")
214+
.command("bucket")
215+
.alias("buckets")
216+
.description("Pulling your Appwrite buckets")
214217
.action(actionRunner(pullBucket))
215218

216219
pull
217-
.command("teams")
218-
.description("Pull your {{ spec.title|caseUcfirst }} teams")
220+
.command("team")
221+
.alias("teams")
222+
.description("Pulling your Appwrite teams")
219223
.action(actionRunner(pullTeam))
220224

221225
pull
222-
.command("topics")
223-
.description("Pull your {{ spec.title|caseUcfirst }} messaging topics")
226+
.command("topic")
227+
.alias("topics")
228+
.description("Initialise your Appwrite messaging topics")
224229
.action(actionRunner(pullMessagingTopic))
225230

226231
module.exports = {

templates/cli/lib/commands/push.js.twig

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1335,6 +1335,7 @@ const pushMessagingTopic = async ({ returnOnZero } = { returnOnZero: false }) =>
13351335
const push = new Command("push")
13361336
.alias('deploy')
13371337
.description(commandDescriptions['push'])
1338+
.action(actionRunner(pushResources));
13381339

13391340
push
13401341
.command("all")
@@ -1347,29 +1348,34 @@ push
13471348
.action(actionRunner(pushProject));
13481349

13491350
push
1350-
.command("functions")
1351+
.command("function")
1352+
.alias("functions")
13511353
.description("Push functions in the current directory.")
1352-
.option(`--functionId <functionId>`, `Function ID`)
1353-
.option(`--async`, `Don't wait for functions deployments status`)
1354+
.option(`-f, --functionId <functionId>`, `Function ID`)
1355+
.option(`-A, --async`, `Don't wait for functions deployments status`)
13541356
.action(actionRunner(pushFunction));
13551357

13561358
push
1357-
.command("collections")
1359+
.command("collection")
1360+
.alias("collections")
13581361
.description("Push collections in the current project.")
13591362
.action(actionRunner(pushCollection));
13601363

13611364
push
1362-
.command("buckets")
1365+
.command("bucket")
1366+
.alias("buckets")
13631367
.description("Push buckets in the current project.")
13641368
.action(actionRunner(pushBucket));
13651369

13661370
push
1367-
.command("teams")
1371+
.command("team")
1372+
.alias("teams")
13681373
.description("Push teams in the current project.")
13691374
.action(actionRunner(pushTeam));
13701375

13711376
push
1372-
.command("topics")
1377+
.command("topic")
1378+
.alias("topics")
13731379
.description("Push messaging topics in the current project.")
13741380
.action(actionRunner(pushMessagingTopic));
13751381

0 commit comments

Comments
 (0)