mirror of
https://github.com/Kong/insomnia.git
synced 2026-10-21 14:25:08 -04:00
37 lines
1.1 KiB
JavaScript
Executable File
37 lines
1.1 KiB
JavaScript
Executable File
// @flow
|
|
import { ConversionTypeMap, generateConfig } from './commands/generate';
|
|
import { getVersion, createCommand } from './util';
|
|
|
|
function makeGenerateCommand(exitOverride: boolean) {
|
|
// inso generate
|
|
const generate = createCommand(exitOverride, 'generate').description('Code generation utilities');
|
|
|
|
const conversionTypes = Object.keys(ConversionTypeMap).join(', ');
|
|
|
|
// inso generate config -t kubernetes config.yaml
|
|
generate
|
|
.command('config <filePath>')
|
|
.description('Generate configuration from an api spec')
|
|
.requiredOption(
|
|
'-t, --type <value>',
|
|
`the type of configuration to generate, options are [${conversionTypes}]`,
|
|
)
|
|
.option('-o, --output <path>', 'the output path')
|
|
.action((filePath, opts) => generateConfig({ filePath, ...opts }));
|
|
|
|
return generate;
|
|
}
|
|
|
|
export function go(args?: Array<string>, exitOverride?: boolean): void {
|
|
if (!args) {
|
|
args = process.argv;
|
|
}
|
|
|
|
// inso -v
|
|
createCommand(!!exitOverride)
|
|
.version(getVersion(), '-v, --version')
|
|
.description('A CLI for Insomnia!')
|
|
.addCommand(makeGenerateCommand(!!exitOverride))
|
|
.parse(args);
|
|
}
|