Skip to content

Commit 898a066

Browse files
Merge pull request #619 from appwrite/fix-cli
fix: cli errors
2 parents 115f6a9 + 91f05bb commit 898a066

File tree

8 files changed

+244
-146
lines changed

8 files changed

+244
-146
lines changed

composer.lock

Lines changed: 207 additions & 144 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 6 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/cli/index.js.twig

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
#! /usr/bin/env node
2+
3+
/** Required to set max width of the help commands */
4+
const oldWidth = process.stdout.columns
5+
process.stdout.columns = 100
6+
/** ---------------------------------------------- */
7+
28
const program = require("commander");
39
const chalk = require("chalk");
410
const { version } = require("./package.json");
@@ -15,6 +21,10 @@ const { {{ service.name | caseLower }} } = require("./lib/commands/{{ service.na
1521

1622
program
1723
.description(commandDescriptions['main'])
24+
.configureHelp({
25+
helpWidth: process.stdout.columns || 80,
26+
sortSubcommands: true
27+
})
1828
.version(version, "-v, --version")
1929
.option("--verbose", "Show complete error log")
2030
.option("--json", "Output in JSON format")
@@ -36,4 +46,5 @@ program
3646
{% endfor %}
3747
.addCommand(client)
3848
.parse(process.argv);
39-
49+
50+
process.stdout.columns = oldWidth;

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ const { sdkForProject, sdkForConsole } = require('../sdks')
1010
const { parse, actionRunner, parseInteger, parseBool, commandDescriptions, success, log } = require('../parser')
1111
const { localConfig, globalConfig } = require("../config");
1212

13-
const {{ service.name | caseLower }} = new Command("{{ service.name | caseLower }}").description(commandDescriptions['{{ service.name | caseLower }}'])
13+
const {{ service.name | caseLower }} = new Command("{{ service.name | caseLower }}").description(commandDescriptions['{{ service.name | caseLower }}']).configureHelp({
14+
helpWidth: process.stdout.columns || 80
15+
})
1416

1517
{% for method in service.methods %}
1618
const {{ service.name | caseLower }}{{ method.name | caseUcfirst }} = async ({ {% for parameter in method.parameters.all %}{{ parameter.name | caseCamel | escapeKeyword }}, {% endfor %}parseOutput = true, sdk = undefined{% if 'multipart/form-data' in method.consumes %}, onProgress = () => {}{% endif %}{% if method.type == 'location' %}, destination{% endif %}}) => {

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ const awaitPools = {
143143

144144
const deploy = new Command("deploy")
145145
.description(commandDescriptions['deploy'])
146+
.configureHelp({
147+
helpWidth: process.stdout.columns || 80
148+
})
146149
.action(actionRunner(async (_options, command) => {
147150
command.help()
148151
}));

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ const { accountCreateEmailSession, accountDeleteSession } = require("./account")
1010

1111
const login = new Command("login")
1212
.description(commandDescriptions['login'])
13+
.configureHelp({
14+
helpWidth: process.stdout.columns || 80
15+
})
1316
.action(actionRunner(async () => {
1417
const answers = await inquirer.prompt(questionsLogin)
1518

@@ -27,6 +30,9 @@ const login = new Command("login")
2730

2831
const logout = new Command("logout")
2932
.description(commandDescriptions['logout'])
33+
.configureHelp({
34+
helpWidth: process.stdout.columns || 80
35+
})
3036
.action(actionRunner(async () => {
3137
let client = await sdkForConsole();
3238

@@ -43,6 +49,9 @@ const logout = new Command("logout")
4349

4450
const client = new Command("client")
4551
.description(commandDescriptions['client'])
52+
.configureHelp({
53+
helpWidth: process.stdout.columns || 80
54+
})
4655
.option("--selfSigned <value>", "Configure the CLI to use a self-signed certificate ( true or false )", parseBool)
4756
.option("--endpoint <endpoint>", "Set your Appwrite server endpoint")
4857
.option("--projectId <projectId>", "Set your Appwrite project ID")

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ const { success, log, actionRunner, commandDescriptions } = require("../parser")
1414

1515
const init = new Command("init")
1616
.description(commandDescriptions['init'])
17+
.configureHelp({
18+
helpWidth: process.stdout.columns || 80
19+
})
1720
.action(actionRunner(async (_options, command) => {
1821
command.help();
1922
}));

templates/cli/lib/parser.js.twig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ const logo = {{ language.params.logo | raw }};
149149

150150
const commandDescriptions = {
151151
"account": `The account command allows you to authenticate and manage a user account.`,
152+
"graphql": `The graphql command allows you to query and mutate any resource type on your Appwrite server.`,
152153
"avatars": `The avatars command aims to help you complete everyday tasks related to your app image, icons, and avatars.`,
153154
"databases": `The databases command allows you to create structured collections of documents, query and filter lists of documents.`,
154155
"deploy": `The deploy command provides a convenient wrapper for deploying your functions and collections.`,

0 commit comments

Comments
 (0)