This repository has been archived by the owner on Apr 5, 2023. It is now read-only.
forked from LamaAni/infer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvscode_snippets.json
68 lines (68 loc) · 1.93 KB
/
vscode_snippets.json
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
{
"infer_class_argument": {
"prefix": "@infer-class-arg",
"body": [
"/** ${3:description} */",
"this.${1:name} = '${2:value}'",
"/** @type {CliArgument} */",
"this.__$${1:name} = {",
" type: 'named',",
" environmentVariable: 'IFR_${1/(.*)/${1:/upcase}/}',",
" default: this.${1:name},",
" description: '${3:description}',",
"}"
]
},
"infer_simple_command_line": {
"prefix": "@infer-simple-command-line",
"body": [
"const {Cli} = require('infer')",
"const cli = new Cli({name: '${1:name}'})",
"cli.default(() => {",
" // The default action",
" cli.logger.error('No command sepcified')",
" throw new Error('no command specified')",
"})",
"",
"if (require.main == module)",
" cli.parse().catch((err) => {",
" console.error(err)",
" process.exit(err.code || 1)",
" })"
]
},
"infer_oo_command_line_parser": {
"prefix": "@infer-oo-command-line-parser",
"body": [
"const {Cli} = require('../src/index')",
"",
"const cli = new Cli({name: '${1:name}'})",
"class CliApp {",
" constructor() {",
" /** The argument that is passed to the object before run. */",
" this.arg = 'default value'",
" /** @type {CliArgument} */",
" this.__$arg = {",
" type: 'named',",
" environmentVariable: 'IFR_ARG',",
" default: this.arg,",
" description: 'The argument that is passed to the object before run.',",
" }",
" }",
"",
" run() {",
" cli.logger.info('Arg = ' + this.arg)",
" }",
"}",
"",
"const app = new CliApp()",
"cli.default(() => app.run(), app)",
"",
"if (require.main == module)",
" cli.parse().catch((err) => {",
" console.error(err)",
" process.exit(err.code || 1)",
" })"
]
}
}