Skip to content
This repository was archived by the owner on Aug 22, 2023. It is now read-only.

Commit 743ac50

Browse files
committed
fix: allow setting flag to skip parsing
1 parent afddb87 commit 743ac50

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

src/command.ts

+11-6
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default abstract class Command {
3333
static args: args.IArg[] = []
3434
static plugin: Config.IPlugin | undefined
3535
static examples: string[] | undefined
36+
static parse: boolean = true
3637

3738
/**
3839
* instantiate and run the command
@@ -56,9 +57,9 @@ export default abstract class Command {
5657
return convertToCached(this, opts)
5758
}
5859

59-
argv: string[]
60-
flags: flags.Output
61-
args: args.Output
60+
argv!: string[]
61+
flags!: flags.Output
62+
args!: args.Output
6263

6364
// prevent setting things that need to be static
6465
description!: null
@@ -77,6 +78,13 @@ export default abstract class Command {
7778
this.debug = require('debug')(this.ctor.id ? `${config.bin}:${this.ctor.id}` : config.bin)
7879
this.debug('init version: %s argv: %o', this.ctor._base, argv)
7980
cli.config.context.command = _.compact([this.ctor.id, ...argv]).join(' ')
81+
cli.config.context.version = config.userAgent
82+
if (config.debug) cli.config.debug = true
83+
cli.config.errlog = config.errlog
84+
if (!this.ctor.parse) {
85+
this.argv = argv.slice(1)
86+
return
87+
}
8088
try {
8189
const parse = deps.Parser.parse({
8290
argv,
@@ -93,9 +101,6 @@ export default abstract class Command {
93101
}
94102
throw err
95103
}
96-
cli.config.context.version = config.userAgent
97-
if (config.debug) cli.config.debug = true
98-
cli.config.errlog = config.errlog
99104
}
100105

101106
get ctor(): typeof Command {

0 commit comments

Comments
 (0)