Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Schniz/cmd-ts. 💻 A type-driven command line argument parser cmd-ts.now.sh
Something went wrong. Try again.
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849import { subcommands, mutuallyExclusive, command, option, string, run, number, flag,} from '../src';
const sub1 = command({ name: 'sub1', args: { name: option({ type: string, long: 'name' }), mutually: mutuallyExclusive({ nickname: option({ long: 'nick' }), age: option({ long: 'age', type: number }), }), }, handler: ({ name, mutually }) => { console.log({ name }); console.log({ mutually }); },});
const deploy = command({ name: 'deploy', args: { where: mutuallyExclusive({ staging: flag({ long: 'staging' }), production: flag({ long: 'production' }), }), }, handler: ({ where }) => { console.log(`deploying to`, where); },});
const nested = subcommands({ name: 'subcmds', cmds: { sub1, deploy, },});
run(nested, process.argv.slice(2));