mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-18 21:27:51 +00:00
Improve command usage format consistency in 'balena help' output
Change-type: patch Signed-off-by: Paulo Castro <paulo@balena.io>
This commit is contained in:
parent
1bedf937f8
commit
b69ba0b617
@ -19,6 +19,7 @@ import * as ent from 'ent';
|
||||
import * as _ from 'lodash';
|
||||
|
||||
import { getManualSortCompareFunction } from '../../lib/utils/helpers';
|
||||
import { capitanoizeOclifUsage } from '../../lib/utils/oclif-utils';
|
||||
import { CapitanoCommand, Category, Document, OclifCommand } from './doc-types';
|
||||
import * as utils from './utils';
|
||||
|
||||
@ -106,7 +107,7 @@ function renderToc(categories: Category[]): string[] {
|
||||
const signature =
|
||||
typeof command === 'object'
|
||||
? command.signature // Capitano
|
||||
: utils.capitanoizeOclifUsage(command.usage); // oclif
|
||||
: capitanoizeOclifUsage(command.usage); // oclif
|
||||
return `\t- [${ent.encode(signature)}](${getAnchor(signature)})`;
|
||||
})
|
||||
.join('\n'),
|
||||
|
@ -51,16 +51,6 @@ export function parseCapitanoOption(option: OptionDefinition): string {
|
||||
return ent.encode(result);
|
||||
}
|
||||
|
||||
/** Convert e.g. 'env add NAME [VALUE]' to 'env add <name> [value]' */
|
||||
export function capitanoizeOclifUsage(
|
||||
oclifUsage: string | string[] | undefined,
|
||||
): string {
|
||||
return (oclifUsage || '')
|
||||
.toString()
|
||||
.replace(/(?<=\s)[A-Z]+(?=(\s|$))/g, match => `<${match}>`)
|
||||
.toLowerCase();
|
||||
}
|
||||
|
||||
export class MarkdownFileParser {
|
||||
constructor(public mdFilePath: string) {}
|
||||
|
||||
|
@ -20,6 +20,8 @@ import * as Bluebird from 'bluebird';
|
||||
import * as _ from 'lodash';
|
||||
import * as path from 'path';
|
||||
|
||||
import { capitanoizeOclifUsage } from '../utils/oclif-utils';
|
||||
|
||||
export async function getOclifHelpLinePairs(): Promise<
|
||||
Array<[string, string]>
|
||||
> {
|
||||
@ -39,7 +41,7 @@ export async function getOclifHelpLinePairs(): Promise<
|
||||
|
||||
function getCmdUsageDescriptionLinePair(cmdModule: any): [string, string] {
|
||||
const cmd: typeof Command = cmdModule.default;
|
||||
const usage = (cmd.usage || '').toString().toLowerCase();
|
||||
const usage = capitanoizeOclifUsage(cmd.usage);
|
||||
let description = '';
|
||||
// note: [^] matches any characters (including line breaks), achieving the
|
||||
// same effect as the 's' regex flag which is only supported by Node 9+
|
||||
|
@ -47,3 +47,13 @@ export class CommandHelp {
|
||||
return array.filter((a): a is T => !!a);
|
||||
}
|
||||
}
|
||||
|
||||
/** Convert e.g. 'env add NAME [VALUE]' to 'env add <name> [value]' */
|
||||
export function capitanoizeOclifUsage(
|
||||
oclifUsage: string | string[] | undefined,
|
||||
): string {
|
||||
return (oclifUsage || '')
|
||||
.toString()
|
||||
.replace(/(?<=\s)[A-Z]+(?=(\s|$))/g, match => `<${match}>`)
|
||||
.toLowerCase();
|
||||
}
|
||||
|
@ -58,9 +58,9 @@ Additional commands:
|
||||
device rm <uuid> remove a device
|
||||
device shutdown <uuid> shutdown a device
|
||||
devices supported list all supported devices
|
||||
env add name [value] add an environment or config variable to an application or device
|
||||
env rename id value change the value of an environment variable for an app or device
|
||||
env rm id remove an environment variable from an application or device
|
||||
env add <name> [value] add an environment or config variable to an application or device
|
||||
env rename <id> <value> change the value of an environment variable for an app or device
|
||||
env rm <id> remove an environment variable from an application or device
|
||||
envs list the environment or config variables of an app or device
|
||||
key <id> list a single ssh key
|
||||
key add <name> [path] add a SSH key to balena
|
||||
|
Loading…
Reference in New Issue
Block a user