Skip to content

Commit 284bc48

Browse files
committed
Improve CLI aliases
1 parent 4b3a3e1 commit 284bc48

File tree

4 files changed

+39
-29
lines changed

4 files changed

+39
-29
lines changed

templates/cli/index.js.twig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ program
2626
sortSubcommands: true
2727
})
2828
.version(version, "-v, --version")
29-
.option("--verbose", "Show complete error log")
30-
.option("--json", "Output in JSON format")
29+
.option("-V, --verbose", "Show complete error log")
30+
.option("-j, --json", "Output in JSON format")
3131
.on("option:json", () => {
3232
cliConfig.json = true;
3333
})

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

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ 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, drawTable } = require("../parser");
6+
const { actionRunner, success, parseBool, commandDescriptions, error, parse, drawTable, cliConfig } = require("../parser");
77
{% if sdk.test != "true" %}
88
const { questionsLogin, questionsListFactors, questionsMfaChallenge } = require("../questions");
99
const { accountUpdateMfaChallenge, accountCreateMfaChallenge, accountGet, accountCreateEmailPasswordSession, accountDeleteSession } = require("./account");
1010

1111
const whoami = new Command("whoami")
1212
.description(commandDescriptions['whoami'])
13-
.option("-j, --json", "Output in JSON format")
14-
.action(actionRunner(async ({ json }) => {
13+
.action(actionRunner(async () => {
1514
if (globalConfig.getEndpoint() === '' || globalConfig.getCookie() === '') {
1615
error("No user is signed in. To sign in, run: appwrite login ");
1716
return;
@@ -39,9 +38,9 @@ const whoami = new Command("whoami")
3938
'MFA enabled': account.mfa ? 'Yes' : 'No'
4039
}
4140
];
42-
if (json) {
43-
console.log(data);
4441

42+
if(cliConfig.json) {
43+
console.log(data);
4544
return;
4645
}
4746

@@ -129,12 +128,12 @@ const client = new Command("client")
129128
.configureHelp({
130129
helpWidth: process.stdout.columns || 80
131130
})
132-
.option("--selfSigned <value>", "Configure the CLI to use a self-signed certificate ( true or false )", parseBool)
133-
.option("--endpoint <endpoint>", "Set your Appwrite server endpoint")
134-
.option("--projectId <projectId>", "Set your Appwrite project ID")
135-
.option("--key <key>", "Set your Appwrite server's API key")
136-
.option("--debug", "Print CLI debug information")
137-
.option("--reset", "Reset the CLI configuration")
131+
.option("-ss, --selfSigned <value>", "Configure the CLI to use a self-signed certificate ( true or false )", parseBool)
132+
.option("-e, --endpoint <endpoint>", "Set your Appwrite server endpoint")
133+
.option("-p, --projectId <projectId>", "Set your Appwrite project ID")
134+
.option("-k, --key <key>", "Set your Appwrite server's API key")
135+
.option("-d, --debug", "Print CLI debug information")
136+
.option("-r, --reset", "Reset the CLI configuration")
138137
.action(actionRunner(async ({ selfSigned, endpoint, projectId, key, debug, reset }, command) => {
139138
if (selfSigned == undefined && endpoint == undefined && projectId == undefined && key == undefined && debug == undefined && reset == undefined) {
140139
command.help()

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,28 +258,33 @@ pull
258258

259259
pull
260260
.command("function")
261+
.alias("functions")
261262
.description("Pulling your {{ spec.title|caseUcfirst }} cloud function")
262263
.action(actionRunner(pullFunction))
263264

264265
pull
265266
.command("collection")
267+
.command("collections")
266268
.description("Pulling your {{ spec.title|caseUcfirst }} collections")
267-
.option(`--databaseId <databaseId>`, `Database ID`)
268-
.option(`--all`, `Flag to pullialize all databases`)
269+
.option(`-d, --databaseId <databaseId>`, `Database ID`)
270+
.option(`-a, --all`, `Flag to pullialize all databases`)
269271
.action(actionRunner(pullCollection))
270272

271273
pull
272274
.command("bucket")
275+
.command("buckets")
273276
.description("Pulling your Appwrite buckets")
274277
.action(actionRunner(pullBucket))
275278

276279
pull
277280
.command("team")
281+
.command("teams")
278282
.description("Pulling your Appwrite teams")
279283
.action(actionRunner(pullTeam))
280284

281285
pull
282286
.command("topic")
287+
.command("topics")
283288
.description("Initialise your Appwrite messaging topics")
284289
.action(actionRunner(pullMessagingTopic))
285290

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

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1101,46 +1101,52 @@ const pushMessagingTopic = async ({ all, yes } = {}) => {
11011101
}
11021102

11031103
const push = new Command("push")
1104+
.alias("deploy")
11041105
.description(commandDescriptions['push'])
1105-
.option(`--all`, `Flag to push all resources`)
1106-
.option(`--yes`, `Flag to confirm all warnings`)
1106+
.option(`-a, --all`, `Flag to push all resources`)
1107+
.option(`-y, --yes`, `Flag to confirm all warnings`)
11071108
.action(actionRunner(pushResources));
11081109

11091110
push
11101111
.command("function")
1112+
.alias("functions")
11111113
.description("Push functions in the current directory.")
1112-
.option(`--functionId <functionId>`, `Function ID`)
1113-
.option(`--all`, `Flag to push all functions`)
1114-
.option(`--yes`, `Flag to confirm all warnings`)
1115-
.option(`--async`, `Don't wait for functions deployments status`)
1114+
.option(`-f, --functionId <functionId>`, `Function ID`)
1115+
.option(`-a, --all`, `Flag to push all functions`)
1116+
.option(`-y, --yes`, `Flag to confirm all warnings`)
1117+
.option(`-A, --async`, `Don't wait for functions deployments status`)
11161118
.action(actionRunner(pushFunction));
11171119

11181120
push
11191121
.command("collection")
1122+
.alias("collections")
11201123
.description("Push collections in the current project.")
1121-
.option(`--all`, `Flag to push all collections`)
1122-
.option(`--yes`, `Flag to confirm all warnings`)
1124+
.option(`-a, --all`, `Flag to push all collections`)
1125+
.option(`-a, --yes`, `Flag to confirm all warnings`)
11231126
.action(actionRunner(pushCollection));
11241127

11251128
push
11261129
.command("bucket")
1130+
.alias("buckets")
11271131
.description("Push buckets in the current project.")
1128-
.option(`--all`, `Flag to push all buckets`)
1129-
.option(`--yes`, `Flag to confirm all warnings`)
1132+
.option(`-a, --all`, `Flag to push all buckets`)
1133+
.option(`-y, --yes`, `Flag to confirm all warnings`)
11301134
.action(actionRunner(pushBucket));
11311135

11321136
push
11331137
.command("team")
1138+
.alias("teams")
11341139
.description("Push teams in the current project.")
1135-
.option(`--all`, `Flag to push all teams`)
1136-
.option(`--yes`, `Flag to confirm all warnings`)
1140+
.option(`-a, --all`, `Flag to push all teams`)
1141+
.option(`-y, --yes`, `Flag to confirm all warnings`)
11371142
.action(actionRunner(pushTeam));
11381143

11391144
push
11401145
.command("topic")
1146+
.alias("topics")
11411147
.description("Push messaging topics in the current project.")
1142-
.option(`--all`, `Flag to deploy all topics`)
1143-
.option(`--yes`, `Flag to confirm all warnings`)
1148+
.option(`-a, --all`, `Flag to deploy all topics`)
1149+
.option(`-y, --yes`, `Flag to confirm all warnings`)
11441150
.action(actionRunner(pushMessagingTopic));
11451151

11461152
module.exports = {

0 commit comments

Comments
 (0)