-
Notifications
You must be signed in to change notification settings - Fork 0
/
bar.ts
32 lines (26 loc) · 777 Bytes
/
bar.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import {Command, flags} from '@oclif/command'
export default class Hello extends Command {
static description = 'describe the command here'
static examples = [
`$ oclif-example hello
hello world from ./src/hello.ts!
`,
`$ oclif-example hello --name myname
hello myname from .src/hello.ts!
`,
]
static flags = {
// flag with a value (-n, --name=VALUE)
name: flags.string({char: 'n', description: 'name to print'}),
force: flags.boolean({char: 'f'}),
}
static args = [{name: 'file'}]
async run() {
const {args, flags} = this.parse(Hello)
const name = flags.name || 'world'
this.log(`hello ${name} from ${__filename}`)
if (args.file && flags.force) {
this.log(`you input --force and --file: ${args.file}`)
}
}
}