Skip to content

Commit 8cf8349

Browse files
committed
feat: set max width for help commands
1 parent faa9bb0 commit 8cf8349

File tree

6 files changed

+36
-2
lines changed

6 files changed

+36
-2
lines changed

package-lock.json

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

templates/cli/index.js.twig

+12-1
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+
let 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

+3-1
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

+3
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

+9
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

+3
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
}));

0 commit comments

Comments
 (0)