-
-
Notifications
You must be signed in to change notification settings - Fork 169
/
init.ts
27 lines (22 loc) · 996 Bytes
/
init.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
import { Flags, Args } from '@oclif/core';
import Command from '../../../base';
import { initContext } from '../../../models/Context';
export default class ContextInit extends Command {
static description = 'Initialize context';
static flags = {
help: Flags.help({ char: 'h' }),
};
static contextFilePathMessage = `Specify directory in which context file should be created:
- current directory : asyncapi config context init . (default)
- root of current repository : asyncapi config context init ./
- user's home directory : asyncapi config context init ~`;
static args = {
'context-file-path': Args.string({description: `${ContextInit.contextFilePathMessage}`, required: false})
};
async run() {
const { args } = await this.parse(ContextInit);
const contextFilePath = args['context-file-path'];
const contextWritePath = await initContext(contextFilePath as string);
this.log(`Initialized context ${contextWritePath}`);
}
}