Sade says it's in single mode when single mode is explicitly disabled
selfagency opened this issue · comments
daniel sieradski commented
My code:
const app = async () => {
consola.log(tagline)
const bus = new EventEmitter()
try {
const cli = sade('udd <command> [options]', false)
// configure the cli options
cli
.version('0.1.0')
.option('-p, --project', 'Google Cloud Project ID')
.option('-y, --confirm', 'Non-iteractive, confirm all actions')
rollback(cli, bus)
cli.parse(process.argv)
} catch (err) {
// fail gracefully
consola.error(err)
process.exit(1)
}
}
The result, which I also get if I leave isSingle
undefined:
ERROR Disable "single" mode to add commands 10:31:25
at Sade.command (node_modules/sade/lib/index.js:25:10)
at rollback (src/lib/rollback.ts:14:6)
at app (src/main.ts:21:19)
at Object.<anonymous> (src/main.ts:31:1)
at Module._compile (internal/modules/cjs/loader.js:1085:14)
at Module.m._compile (node_modules/ts-node/src/index.ts:1371:23)
at Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Object.require.extensions.<computed> [as .ts] (node_modules/ts-node/src/index.ts:1374:12)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:14)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
This works, though:
cli.single = true
Luke Edwards commented
Hey, so the documentation actually doesn't mention it (oops), but isSingle
is always true when the usage text has a space in it: https://github.com/lukeed/sade/blob/master/lib/index.js#L10
The parameter is there for explicitly turning on single-command mode when, for example, you don't have custom usage text.
For your app, you should have this instead, since you're just redefining the default usage text (which is generated automatically):
cli = sade('udd');
cli.version('...')
Luke Edwards commented
Closing, but let me know if you have any follow-up questions 👍