Add validators schema and code templates

This commit is contained in:
2026-01-30 07:11:06 +00:00
parent ed4f878c31
commit 3185903d20

View File

@@ -0,0 +1,52 @@
#!/usr/bin/env node
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
const argv = yargs(hideBin(process.argv))
.command('{{spec.name}}', '{{spec.description}}', (yargs) => {
return yargs
.option('version', {
alias: 'v',
type: 'boolean',
description: 'Show version'
})
{{#each spec.globalOptions}}
.option('{{name}}', {
{{#if short}}alias: '{{short}}',{{/if}}
type: '{{type}}',
description: '{{escape description}}'{{#if default}}, default: '{{defaultValue}}'{{/if}}
})
{{/each}}
.command('{{#each spec.commands}}{{name}}{{#unless @last}}', '{{@index}}', {{/unless}}{{/each}}', '{{escape description}}', (yargs) => {
return yargs
{{#each ../spec.commands}}
.command('{{name}}', '{{escape description}}', (yargs) => {
return yargs
{{#each arguments}}
.positional('{{name}}', {
describe: '{{escape description}}',
type: '{{type}}'{{#if required}}, demandOption: true{{/if}}
})
{{/each}}
{{#each options}}
.option('{{name}}', {
{{#if short}}alias: '{{short}}',{{/if}}
describe: '{{escape description}}',
type: '{{type}}'
})
{{/each}}
}, (argv) => {
console.log('Running {{name}} command');
})
{{/each}}
}, (argv) => {
if (argv.version) {
console.log('{{spec.name}} v{{spec.version}}');
} else {
console.log('Use --help to see available commands');
}
})
})
.help()
.parse();