Compare commits

...

1 Commits

Author SHA1 Message Date
Erika Rowland
b86d4a6200 [cli] Migrate vc domains to updated argument parsing utilities 2024-05-03 16:02:28 -07:00
3 changed files with 44 additions and 49 deletions

View File

@@ -116,7 +116,7 @@ export const domainsCommand: Command = {
},
{
name: 'limit',
shorthand: 'n',
shorthand: null,
description:
'Number of results to return per page (default: 20, max: 100)',
argument: 'NUMBER',
@@ -125,12 +125,13 @@ export const domainsCommand: Command = {
},
{
name: 'force',
shorthand: 'f',
shorthand: null,
type: Boolean,
deprecated: false,
description:
'Force a domain on a project and remove it from an existing one',
},
{ name: 'code', shorthand: null, type: String, deprecated: false },
],
examples: [
{

View File

@@ -1,5 +1,5 @@
import Client from '../../util/client';
import getArgs from '../../util/get-args';
import { parseArguments } from '../../util/get-args';
import getSubcommand from '../../util/get-subcommand';
import handleError from '../../util/handle-error';
import add from './add';
@@ -11,6 +11,7 @@ import rm from './rm';
import move from './move';
import { domainsCommand } from './command';
import { help } from '../help';
import { getFlagsSpecification } from '../../util/get-flags-specification';
const COMMAND_CONFIG = {
add: ['add'],
@@ -23,45 +24,42 @@ const COMMAND_CONFIG = {
};
export default async function main(client: Client) {
let argv;
let parsedArgs;
const flagsSpecification = getFlagsSpecification(domainsCommand.options);
try {
argv = getArgs(client.argv.slice(2), {
'--code': String,
'--yes': Boolean,
'--force': Boolean,
'--next': Number,
'-N': '--next',
'-y': '--yes',
'--limit': Number,
});
parsedArgs = parseArguments(client.argv.slice(2), flagsSpecification);
} catch (error) {
handleError(error);
return 1;
}
if (argv['--help']) {
if (parsedArgs.flags['--help']) {
client.output.print(
help(domainsCommand, { columns: client.stderr.columns })
);
return 2;
}
const { subcommand, args } = getSubcommand(argv._.slice(1), COMMAND_CONFIG);
const { subcommand, args } = getSubcommand(
parsedArgs.args.slice(1),
COMMAND_CONFIG
);
switch (subcommand) {
case 'add':
return add(client, argv, args);
return add(client, parsedArgs.flags, args);
case 'inspect':
return inspect(client, argv, args);
return inspect(client, parsedArgs.flags, args);
case 'move':
return move(client, argv, args);
return move(client, parsedArgs.flags, args);
case 'buy':
return buy(client, argv, args);
return buy(client, parsedArgs.flags, args);
case 'rm':
return rm(client, argv, args);
return rm(client, parsedArgs.flags, args);
case 'transferIn':
return transferIn(client, argv, args);
return transferIn(client, parsedArgs.flags, args);
default:
return ls(client, argv, args);
return ls(client, parsedArgs.flags, args);
}
}

View File

@@ -1195,23 +1195,20 @@ exports[`help command > domains help output snapshots > domains help column widt
Options:
-f, --force Force a domain
on a project
and remove it
from an
existing one
-n, --limit <NUMBER> Number of
results to
return per page
(default: 20,
max: 100)
-N, --next Show next page
of results
-y, --yes Skip the
confirmation
prompt when
removing a
domain
--force Force a domain on a
project and remove
it from an existing
one
--limit <NUMBER> Number of results to
return per page
(default: 20, max:
100)
-N, --next Show next page of
results
-y, --yes Skip the
confirmation prompt
when removing a
domain
Global Options:
@@ -1286,12 +1283,11 @@ exports[`help command > domains help output snapshots > domains help column widt
Options:
-f, --force Force a domain on a project and remove it from an
existing one
-n, --limit <NUMBER> Number of results to return per page (default: 20, max:
100)
-N, --next Show next page of results
-y, --yes Skip the confirmation prompt when removing a domain
--force Force a domain on a project and remove it from an existing
one
--limit <NUMBER> Number of results to return per page (default: 20, max: 100)
-N, --next Show next page of results
-y, --yes Skip the confirmation prompt when removing a domain
Global Options:
@@ -1342,10 +1338,10 @@ exports[`help command > domains help output snapshots > domains help column widt
Options:
-f, --force Force a domain on a project and remove it from an existing one
-n, --limit <NUMBER> Number of results to return per page (default: 20, max: 100)
-N, --next Show next page of results
-y, --yes Skip the confirmation prompt when removing a domain
--force Force a domain on a project and remove it from an existing one
--limit <NUMBER> Number of results to return per page (default: 20, max: 100)
-N, --next Show next page of results
-y, --yes Skip the confirmation prompt when removing a domain
Global Options: