fork of hey-api/openapi-ts because I need some additional things
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at feat/use-query-options 56 lines 2.0 kB view raw
1import { isEnvironment } from '@hey-api/shared'; 2import { Command, CommanderError } from 'commander'; 3 4import pkg from '../../package.json'; 5import { createClient } from '../index'; 6import { cliToConfig } from './adapter'; 7 8const binName = Object.keys(pkg.bin)[0]!; 9 10const program = new Command() 11 .name(binName) 12 .description('Generate Python code from OpenAPI specifications') 13 .version(isEnvironment('development') ? '[DEVELOPMENT]' : pkg.version); 14 15program 16 .option('-i, --input <path...>', 'OpenAPI specification (path, URL, or string)') 17 .option('-o, --output <path...>', 'Output folder(s)') 18 .option('-c, --client <name>', 'HTTP client to generate') 19 .option('-p, --plugins [names...]', 'Plugins to use') 20 .option('-f, --file <path>', 'Path to config file') 21 .option('-d, --debug', 'Enable debug logging') 22 .option('-s, --silent', 'Suppress all output') 23 .option('-l, --logs <path>', 'Logs folder path') 24 .option('--no-log-file', 'Disable log file output') 25 .option('--dry-run', 'Skip writing files') 26 .option('-w, --watch [interval]', 'Watch for changes') 27 .action(async (options) => { 28 const config = cliToConfig(options); 29 30 const context = await createClient(config as Parameters<typeof createClient>[0]); 31 32 const hasActiveWatch = context[0]?.config.input.some((input) => input.watch?.enabled); 33 34 if (!hasActiveWatch) { 35 process.exit(0); 36 } 37 }); 38 39export async function runCli(): Promise<void> { 40 try { 41 await program.parseAsync(process.argv); 42 } catch (error) { 43 if (error instanceof CommanderError && 'code' in error) { 44 if (error.code === 'commander.optionMissingArgument') { 45 console.error(`\nMissing required argument. Run '${binName} --help' for usage.\n`); 46 } else if (error.code === 'commander.unknownOption') { 47 console.error(`\nUnknown option. Run '${binName} --help' for available options.\n`); 48 } 49 50 process.exit(error.exitCode); 51 } 52 53 console.error('Unexpected error:', error); 54 process.exit(1); 55 } 56}