Use default oclif USAGE message for all commands

Change-type: patch
This commit is contained in:
myarmolinsky 2024-09-30 11:25:43 -04:00
parent 057b37ae38
commit 0847daba1b
86 changed files with 387 additions and 588 deletions

File diff suppressed because it is too large Load Diff

@ -40,8 +40,6 @@ export default class GenerateCmd extends Command {
}),
};
public static usage = 'api-key generate <name>';
public static flags = {
help: cf.help,
};

@ -41,8 +41,6 @@ export default class RevokeCmd extends Command {
}),
};
public static usage = 'api-key revoke <ids>';
public static flags = {
help: cf.help,
};

@ -30,8 +30,6 @@ export default class ApiKeysCmd extends Command {
`;
public static examples = ['$ balena api-keys'];
public static usage = 'api-keys';
public static flags = {
help: cf.help,
user: Flags.boolean({

@ -56,8 +56,6 @@ export default class AppCreateCmd extends Command {
}),
};
public static usage = 'app create <name>';
public static flags = {
organization: Flags.string({
char: 'o',

@ -56,8 +56,6 @@ export default class BlockCreateCmd extends Command {
}),
};
public static usage = 'block create <name>';
public static flags = {
organization: Flags.string({
char: 'o',

@ -84,8 +84,6 @@ ${dockerignoreHelp}
source: Args.string({ description: 'path of project source directory' }),
};
public static usage = 'build [source]';
public static flags = {
arch: Flags.string({
description: 'the architecture to build for',

@ -60,8 +60,6 @@ export default class ConfigGenerateCmd extends Command {
'$ balena config generate --fleet myorg/fleet --version 2.12.7 --network wifi --wifiSsid mySsid --wifiKey abcdefgh --appUpdatePollInterval 15',
];
public static usage = 'config generate';
public static flags = {
version: Flags.string({
description: 'a balenaOS version',

@ -43,8 +43,6 @@ export default class ConfigInjectCmd extends Command {
}),
};
public static usage = 'config inject <file>';
public static flags = {
drive: cf.driveOrImg,
help: cf.help,

@ -36,8 +36,6 @@ export default class ConfigReadCmd extends Command {
'$ balena config read --drive balena.img',
];
public static usage = 'config read';
public static flags = {
drive: cf.driveOrImg,
help: cf.help,

@ -39,8 +39,6 @@ export default class ConfigReconfigureCmd extends Command {
'$ balena config reconfigure --drive balena.img --advanced',
];
public static usage = 'config reconfigure';
public static flags = {
drive: cf.driveOrImg,
advanced: Flags.boolean({

@ -48,8 +48,6 @@ export default class ConfigWriteCmd extends Command {
}),
};
public static usage = 'config write <key> <value>';
public static flags = {
drive: cf.driveOrImg,
help: cf.help,

@ -108,8 +108,6 @@ ${dockerignoreHelp}
image: Args.string({ description: 'the image to deploy' }),
};
public static usage = 'deploy <fleet> [image]';
public static flags = {
source: Flags.string({
description:

@ -41,8 +41,6 @@ export default class DeviceDeactivateCmd extends Command {
}),
};
public static usage = 'device deactivate <uuid>';
public static flags = {
yes: cf.yes,
help: cf.help,

@ -36,8 +36,6 @@ export default class DeviceIdentifyCmd extends Command {
}),
};
public static usage = 'device identify <uuid>';
public static flags = {
help: cf.help,
};

@ -62,8 +62,6 @@ export default class DeviceCmd extends Command {
}),
};
public static usage = 'device <uuid>';
public static flags = {
json: cf.json,
help: cf.help,

@ -74,8 +74,6 @@ export default class DeviceInitCmd extends Command {
'$ balena device init --fleet myFleet --os-version 2.83.21+rev1.prod --drive /dev/disk5 --config config.json --yes',
];
public static usage = 'device init';
public static flags = {
fleet: cf.fleet,
yes: cf.yes,

@ -42,8 +42,6 @@ export default class DeviceLocalModeCmd extends Command {
}),
};
public static usage = 'device local-mode <uuid>';
public static flags = {
enable: Flags.boolean({
description: 'enable local mode',

@ -54,8 +54,6 @@ export default class DeviceMoveCmd extends Command {
}),
};
public static usage = 'device move <uuid(s)>';
public static flags = {
fleet: cf.fleet,
help: cf.help,

@ -47,8 +47,6 @@ export default class DeviceOsUpdateCmd extends Command {
}),
};
public static usage = 'device os-update <uuid>';
public static flags = {
version: Flags.string({
description: 'a balenaOS version',

@ -44,8 +44,6 @@ export default class DevicePinCmd extends Command {
}),
};
public static usage = 'device pin <uuid> [releaseToPinTo]';
public static flags = {
help: cf.help,
};

@ -44,8 +44,6 @@ export default class DevicePublicUrlCmd extends Command {
}),
};
public static usage = 'device public-url <uuid>';
public static flags = {
enable: Flags.boolean({
description: 'enable the public URL',

@ -35,8 +35,6 @@ export default class DevicePurgeCmd extends Command {
'$ balena device purge 55d43b3,23c73a1',
];
public static usage = 'device purge <uuid>';
public static args = {
uuid: Args.string({
description: 'comma-separated list (no blank spaces) of device UUIDs',

@ -35,8 +35,6 @@ export default class DeviceRebootCmd extends Command {
}),
};
public static usage = 'device reboot <uuid>';
public static flags = {
force: cf.force,
help: cf.help,

@ -44,8 +44,6 @@ export default class DeviceRegisterCmd extends Command {
fleet: ca.fleetRequired,
};
public static usage = 'device register <fleet>';
public static flags = {
uuid: Flags.string({
description: 'custom uuid',

@ -43,8 +43,6 @@ export default class DeviceRenameCmd extends Command {
}),
};
public static usage = 'device rename <uuid> [newName]';
public static flags = {
help: cf.help,
};

@ -53,8 +53,6 @@ export default class DeviceRestartCmd extends Command {
}),
};
public static usage = 'device restart <uuid>';
public static flags = {
service: Flags.string({
description:

@ -43,8 +43,6 @@ export default class DeviceRmCmd extends Command {
}),
};
public static usage = 'device rm <uuid(s)>';
public static flags = {
yes: cf.yes,
help: cf.help,

@ -36,8 +36,6 @@ export default class DeviceShutdownCmd extends Command {
}),
};
public static usage = 'device shutdown <uuid>';
public static flags = {
force: cf.force,
help: cf.help,

@ -46,8 +46,6 @@ export default class DeviceStartServiceCmd extends Command {
}),
};
public static usage = 'device start-service <uuid>';
public static flags = {
help: cf.help,
};

@ -46,8 +46,6 @@ export default class DeviceStopServiceCmd extends Command {
}),
};
public static usage = 'device stop-service <uuid>';
public static flags = {
help: cf.help,
};

@ -35,8 +35,6 @@ export default class DeviceTrackFleetCmd extends Command {
}),
};
public static usage = 'device track-fleet <uuid>';
public static flags = {
help: cf.help,
};

@ -53,8 +53,6 @@ export default class DevicesCmd extends Command {
'$ balena devices -f myorg/myfleet',
];
public static usage = 'devices';
public static flags = {
fleet: cf.fleet,
json: cf.json,

@ -21,7 +21,6 @@ import Command from '../../command';
import * as cf from '../../utils/common-flags';
import { getBalenaSdk, getVisuals, stripIndent } from '../../utils/lazy';
import { CommandHelp } from '../../utils/oclif-utils';
export default class DevicesSupportedCmd extends Command {
public static description = stripIndent`
@ -40,11 +39,6 @@ export default class DevicesSupportedCmd extends Command {
'$ balena devices supported --json',
];
public static usage = (
'devices supported ' +
new CommandHelp({ args: DevicesSupportedCmd.args }).defaultUsage()
).trim();
public static flags = {
help: cf.help,
json: Flags.boolean({

@ -92,7 +92,6 @@ export default class EnvAddCmd extends Command {
// Required for supporting empty string ('') `value` args.
public static strict = false;
public static usage = 'env add <name> [value]';
public static flags = {
fleet: { ...cf.fleet, exclusive: ['device'] },

@ -53,8 +53,6 @@ export default class EnvRenameCmd extends Command {
}),
};
public static usage = 'env rename <id> <value>';
public static flags = {
config: ec.booleanConfig,
device: ec.booleanDevice,

@ -52,8 +52,6 @@ export default class EnvRmCmd extends Command {
}),
};
public static usage = 'env rm <id>';
public static flags = {
config: ec.booleanConfig,
device: ec.booleanDevice,

@ -94,8 +94,6 @@ export default class EnvsCmd extends Command {
'$ balena envs --device 7cf02a6 --service MyService',
];
public static usage = 'envs';
public static flags = {
fleet: { ...cf.fleet, exclusive: ['device'] },
config: Flags.boolean({

@ -56,8 +56,6 @@ export default class FleetCreateCmd extends Command {
}),
};
public static usage = 'fleet create <name>';
public static flags = {
organization: Flags.string({
char: 'o',

@ -41,8 +41,6 @@ export default class FleetCmd extends Command {
fleet: ca.fleetRequired,
};
public static usage = 'fleet <fleet>';
public static flags = {
help: cf.help,
view: Flags.boolean({

@ -44,8 +44,6 @@ export default class FleetPinCmd extends Command {
}),
};
public static usage = 'fleet pin <slug> [releaseToPinTo]';
public static flags = {
help: cf.help,
};

@ -40,8 +40,6 @@ export default class FleetPurgeCmd extends Command {
fleet: ca.fleetRequired,
};
public static usage = 'fleet purge <fleet>';
public static flags = {
help: cf.help,
};

@ -48,8 +48,6 @@ export default class FleetRenameCmd extends Command {
}),
};
public static usage = 'fleet rename <fleet> [newName]';
public static flags = {
help: cf.help,
};

@ -39,8 +39,6 @@ export default class FleetRestartCmd extends Command {
fleet: ca.fleetRequired,
};
public static usage = 'fleet restart <fleet>';
public static flags = {
help: cf.help,
};

@ -42,8 +42,6 @@ export default class FleetRmCmd extends Command {
fleet: ca.fleetRequired,
};
public static usage = 'fleet rm <fleet>';
public static flags = {
yes: cf.yes,
help: cf.help,

@ -38,8 +38,6 @@ export default class FleetTrackLatestCmd extends Command {
}),
};
public static usage = 'fleet track-latest <slug>';
public static flags = {
help: cf.help,
};

@ -39,8 +39,6 @@ export default class FleetsCmd extends Command {
public static examples = ['$ balena fleets'];
public static usage = 'fleets';
public static flags = {
help: cf.help,
json: cf.json,

@ -18,7 +18,6 @@
import { Args } from '@oclif/core';
import Command from '../../command';
import { stripIndent } from '../../utils/lazy';
import { CommandHelp } from '../../utils/oclif-utils';
// 'Internal' commands are called during the execution of other commands.
// `osinit` is called during `os initialize`
@ -48,11 +47,6 @@ export default class OsinitCmd extends Command {
}),
};
public static usage = (
'internal osinit ' +
new CommandHelp({ args: OsinitCmd.args }).defaultUsage()
).trim();
public static hidden = true;
public static root = true;
public static offlineCompatible = true;

@ -60,9 +60,6 @@ export default class JoinCmd extends Command {
}),
};
// Hardcoded to preserve camelcase
public static usage = 'join [deviceIpOrHostname]';
public static flags = {
fleet: cf.fleet,
pollInterval: Flags.integer({

@ -29,7 +29,7 @@ export default class KeyAddCmd extends Command {
If \`path\` is omitted, the command will attempt to read the SSH key from stdin.
About SSH keys
About SSH keys
An "SSH key" actually consists of a public/private key pair. A typical name
for the private key file is "id_rsa", and a typical name for the public key
file is "id_rsa.pub". Both key files are saved to your computer (with the
@ -37,7 +37,7 @@ export default class KeyAddCmd extends Command {
saved to your balena account. This means that if you change computers or
otherwise lose the private key, you cannot recover the private key through
your balena account. You can however add new keys, and delete the old ones.
To generate a new SSH key pair, a nice guide can be found in GitHub's docs:
https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent
Skip the step about adding the key to a GitHub account, and instead add it to
@ -61,8 +61,6 @@ export default class KeyAddCmd extends Command {
}),
};
public static usage = 'key add <name> [path]';
public static flags = {
help: cf.help,
};

@ -38,8 +38,6 @@ export default class KeyCmd extends Command {
}),
};
public static usage = 'key <id>';
public static flags = {
help: cf.help,
};

@ -40,8 +40,6 @@ export default class KeyRmCmd extends Command {
}),
};
public static usage = 'key rm <id>';
public static flags = {
yes: cf.yes,
help: cf.help,

@ -27,8 +27,6 @@ export default class KeysCmd extends Command {
`;
public static examples = ['$ balena keys'];
public static usage = 'keys';
public static flags = {
help: cf.help,
};

@ -50,8 +50,6 @@ export default class LeaveCmd extends Command {
}),
};
public static usage = 'leave [deviceIpOrHostname]';
public static flags = {
help: cf.help,
};

@ -40,8 +40,6 @@ export default class LocalConfigureCmd extends Command {
}),
};
public static usage = 'local configure <target>';
public static flags = {
help: cf.help,
};

@ -46,8 +46,6 @@ export default class LocalFlashCmd extends Command {
}),
};
public static usage = 'local flash <image>';
public static flags = {
drive: cf.drive,
yes: cf.yes,

@ -63,8 +63,6 @@ export default class LoginCmd extends Command {
}),
};
public static usage = 'login';
public static flags = {
web: Flags.boolean({
default: false,

@ -26,8 +26,6 @@ export default class LogoutCmd extends Command {
`;
public static examples = ['$ balena logout'];
public static usage = 'logout';
public async run() {
await this.parse(LogoutCmd);
await getBalenaSdk().auth.logout();

@ -61,8 +61,6 @@ export default class LogsCmd extends Command {
}),
};
public static usage = 'logs <device>';
public static flags = {
'max-retry': Flags.integer({
description: stripIndent`

@ -42,8 +42,6 @@ export default class NoteCmd extends Command {
}),
};
public static usage = 'note <|note>';
public static flags = {
device: { exclusive: ['dev'], ...cf.device },
dev: Flags.string({

@ -27,8 +27,6 @@ export default class OrgsCmd extends Command {
`;
public static examples = ['$ balena orgs'];
public static usage = 'orgs';
public static flags = {
help: cf.help,
};

@ -46,8 +46,6 @@ export default class OsBuildConfigCmd extends Command {
}),
};
public static usage = 'os build-config <image> <device-type>';
public static flags = {
advanced: Flags.boolean({
description: 'show advanced configuration options',

@ -92,8 +92,6 @@ export default class OsConfigureCmd extends Command {
}),
};
public static usage = 'os configure <image>';
public static flags = {
advanced: Flags.boolean({
char: 'v',

@ -62,8 +62,6 @@ export default class OsDownloadCmd extends Command {
}),
};
public static usage = 'os download <type>';
public static flags = {
output: Flags.string({
description: 'output path',

@ -48,8 +48,6 @@ export default class OsInitializeCmd extends Command {
}),
};
public static usage = 'os initialize <image>';
public static flags = {
type: cf.deviceType,
drive: cf.drive,

@ -40,8 +40,6 @@ export default class OsVersionsCmd extends Command {
}),
};
public static usage = 'os versions <type>';
public static flags = {
help: cf.help,
esr: Flags.boolean({

@ -80,8 +80,6 @@ export default class PreloadCmd extends Command {
}),
};
public static usage = 'preload <image>';
public static flags = {
fleet: cf.fleet,
commit: Flags.string({

@ -99,8 +99,6 @@ export default class PushCmd extends Command {
}),
};
public static usage = 'push <fleetOrDevice>';
public static flags = {
source: Flags.string({
description: stripIndent`

@ -40,8 +40,6 @@ export default class ReleaseFinalizeCmd extends Command {
'$ balena release finalize 1234567',
];
public static usage = 'release finalize <commitOrId>';
public static flags = {
help: cf.help,
};

@ -42,8 +42,6 @@ export default class ReleaseCmd extends Command {
'$ balena release d3f3151f5ad25ca6b070aa4d08296aca --json',
];
public static usage = 'release <commitOrId>';
public static flags = {
json: cf.json,
help: cf.help,

@ -35,8 +35,6 @@ export default class ReleaseInvalidateCmd extends Command {
'$ balena release invalidate 1234567',
];
public static usage = 'release invalidate <commitOrId>';
public static flags = {
help: cf.help,
};

@ -34,8 +34,6 @@ export default class ReleaseValidateCmd extends Command {
'$ balena release validate 1234567',
];
public static usage = 'release validate <commitOrId>';
public static flags = {
help: cf.help,
};

@ -38,8 +38,6 @@ export default class ReleasesCmd extends Command {
'$ balena releases myorg/myfleet --json',
];
public static usage = 'releases <fleet>';
public static flags = {
json: cf.json,
help: cf.help,

@ -38,8 +38,6 @@ export default class ScanCmd extends Command {
'$ balena scan --verbose',
];
public static usage = 'scan';
public static flags = {
verbose: Flags.boolean({
default: false,

@ -27,8 +27,6 @@ export default class SettingsCmd extends Command {
`;
public static examples = ['$ balena settings'];
public static usage = 'settings';
public static flags = {
help: cf.help,
};

@ -75,8 +75,6 @@ export default class SshCmd extends Command {
}),
};
public static usage = 'ssh <fleetOrDevice> [service]';
public static flags = {
port: Flags.integer({
description: stripIndent`

@ -52,8 +52,6 @@ export default class SupportCmd extends Command {
}),
};
public static usage = 'support <action>';
public static flags = {
device: Flags.string({
description: 'comma-separated list (no spaces) of device UUIDs',

@ -45,8 +45,6 @@ export default class TagRmCmd extends Command {
}),
};
public static usage = 'tag rm <tagKey>';
public static flags = {
fleet: {
...cf.fleet,

@ -58,7 +58,6 @@ export default class TagSetCmd extends Command {
// Required for supporting empty string ('') `value` args.
public static strict = false;
public static usage = 'tag set <tagKey> [value]';
public static flags = {
fleet: {

@ -38,8 +38,6 @@ export default class TagsCmd extends Command {
'$ balena tags --release b376b0e544e9429483b656490e5b9443b4349bd6',
];
public static usage = 'tags';
public static flags = {
fleet: {
...cf.fleet,

@ -78,8 +78,6 @@ export default class TunnelCmd extends Command {
}),
};
public static usage = 'tunnel <deviceOrFleet>';
public static flags = {
port: Flags.string({
description:

@ -27,8 +27,6 @@ export default class UtilAvailableDrivesCmd extends Command {
Does not list system drives.
`;
public static usage = 'util available-drives';
public static flags = {
help: cf.help,
};

@ -49,8 +49,6 @@ export default class VersionCmd extends Command {
`$ balena -v`,
];
public static usage = 'version';
public static offlineCompatible = true;
public static flags = {

@ -27,8 +27,6 @@ export default class WhoamiCmd extends Command {
public static examples = ['$ balena whoami'];
public static usage = 'whoami';
public static authenticated = true;
public async run() {

@ -37,8 +37,6 @@ function getHelpSubject(args: string[]): string | undefined {
}
export default class BalenaHelp extends Help {
public static usage: 'help [command]';
public async showHelp(argv: string[]) {
const chalk = getChalk();
const subject = getHelpSubject(argv);

@ -15,33 +15,7 @@
* limitations under the License.
*/
/**
* This class is a partial copy-and-paste of
* @oclif/plugin-help/command/CommandHelp, which is used to generate oclif's
* command help output.
*/
export class CommandHelp {
constructor(public command: { args?: { [name: string]: any } }) {}
protected arg(name: string, required: boolean): string {
name = name.toUpperCase();
if (required) {
return `${name}`;
}
return `[${name}]`;
}
public defaultUsage(): string {
const argsObject = this.command.args ?? {};
return Object.entries(argsObject)
.filter(([_name, { hidden }]) => !hidden)
.map(([name, { required }]) => this.arg(name, required))
.join(' ');
}
}
/** Convert e.g. 'env add NAME [VALUE]' to 'env add <name> [value]' */
/** Convert e.g. 'env set NAME [VALUE]' to 'env set <name> [value]' */
export function capitanoizeOclifUsage(
oclifUsage: string | string[] | undefined,
): string {