-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore-v1.ts
40 lines (35 loc) · 947 Bytes
/
core-v1.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
33
34
35
36
37
38
39
40
import {Command, Flags, Interfaces} from '@oclif/core'
type Result = {
args: { [name: string]: any }
flags: Interfaces.InferredFlags<typeof CoreV1.flags>
}
export default class CoreV1 extends Command {
static flags = {
optionalString: Flags.string(),
defaultString: Flags.string({
default: 'simple string default',
}),
defaultFnString: Flags.string({
default: async () => Promise.resolve('async fn default'),
}),
}
static args = [
{
name: 'optionalArg',
},
{
name: 'defaultArg',
default: 'simple string default',
},
{
name: 'defaultFnArg',
default: async (): Promise<string> => Promise.resolve('async fn default'),
},
]
static enableJsonFlag = true
async run(): Promise<Result> {
const {args, flags} = await this.parse(CoreV1)
this.log(`hello I am an @oclif/core@v1 plugin from ${this.config.root}!`)
return {args, flags}
}
}