sn-typescript-util 1.3.8 → 1.3.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/snts.js +12 -5
- package/package.json +1 -1
- package/scripts/options.ts +1 -0
- package/scripts/snts.ts +13 -5
package/bin/snts.js
CHANGED
|
@@ -21,7 +21,7 @@ async function doCompile() {
|
|
|
21
21
|
return stdout;
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
|
-
function doOptions(program) {
|
|
24
|
+
function doOptions(program, version) {
|
|
25
25
|
program.parse(process.argv).opts();
|
|
26
26
|
const option = Object.keys(program.opts()).toString();
|
|
27
27
|
const optionKey = option;
|
|
@@ -32,6 +32,9 @@ function doOptions(program) {
|
|
|
32
32
|
compile: () => {
|
|
33
33
|
doCompile();
|
|
34
34
|
},
|
|
35
|
+
help: () => {
|
|
36
|
+
program.help();
|
|
37
|
+
},
|
|
35
38
|
sync: () => {
|
|
36
39
|
doSync();
|
|
37
40
|
},
|
|
@@ -39,7 +42,7 @@ function doOptions(program) {
|
|
|
39
42
|
program.help();
|
|
40
43
|
}
|
|
41
44
|
};
|
|
42
|
-
return handleOptions(program, options, optionKey);
|
|
45
|
+
return handleOptions(program, options, optionKey, version);
|
|
43
46
|
}
|
|
44
47
|
async function doSync() {
|
|
45
48
|
const s = startPrompts('Processing', 'Sync started');
|
|
@@ -74,7 +77,11 @@ function handleError() {
|
|
|
74
77
|
getErrorMsg();
|
|
75
78
|
return process.exit(1);
|
|
76
79
|
}
|
|
77
|
-
function handleOptions(program, options, option) {
|
|
80
|
+
function handleOptions(program, options, option, version) {
|
|
81
|
+
if (option === 'help' || !option) {
|
|
82
|
+
console.log(getDescription(version));
|
|
83
|
+
program.help();
|
|
84
|
+
}
|
|
78
85
|
return (
|
|
79
86
|
shouldShowHelp(program, option) ||
|
|
80
87
|
((hasApplication() && options[option]) || showHelp(program))()
|
|
@@ -109,9 +116,9 @@ async function init() {
|
|
|
109
116
|
'-s, --sync',
|
|
110
117
|
'sync new instance-based src files to the ts directory'
|
|
111
118
|
);
|
|
119
|
+
program.option('-h, --help', 'display help for command');
|
|
112
120
|
program.usage(cyan('[options]'));
|
|
113
|
-
|
|
114
|
-
return doOptions(program);
|
|
121
|
+
return doOptions(program, version);
|
|
115
122
|
}
|
|
116
123
|
function introPrompt(msg) {
|
|
117
124
|
return intro(msg);
|
package/package.json
CHANGED
package/scripts/options.ts
CHANGED
package/scripts/snts.ts
CHANGED
|
@@ -27,7 +27,7 @@ async function doCompile() {
|
|
|
27
27
|
});
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
function doOptions(program: Command) {
|
|
30
|
+
function doOptions(program: Command, version: string) {
|
|
31
31
|
program.parse(process.argv).opts();
|
|
32
32
|
const option: string = Object.keys(program.opts()).toString();
|
|
33
33
|
const optionKey = option as keyof Options;
|
|
@@ -38,6 +38,9 @@ function doOptions(program: Command) {
|
|
|
38
38
|
compile: () => {
|
|
39
39
|
doCompile();
|
|
40
40
|
},
|
|
41
|
+
help: () => {
|
|
42
|
+
program.help();
|
|
43
|
+
},
|
|
41
44
|
sync: () => {
|
|
42
45
|
doSync();
|
|
43
46
|
},
|
|
@@ -45,7 +48,7 @@ function doOptions(program: Command) {
|
|
|
45
48
|
program.help();
|
|
46
49
|
}
|
|
47
50
|
};
|
|
48
|
-
return handleOptions(program, options, optionKey);
|
|
51
|
+
return handleOptions(program, options, optionKey, version);
|
|
49
52
|
}
|
|
50
53
|
|
|
51
54
|
async function doSync() {
|
|
@@ -91,8 +94,13 @@ function handleError() {
|
|
|
91
94
|
function handleOptions(
|
|
92
95
|
program: Command,
|
|
93
96
|
options: Options,
|
|
94
|
-
option: keyof Options
|
|
97
|
+
option: keyof Options,
|
|
98
|
+
version: string
|
|
95
99
|
) {
|
|
100
|
+
if (option === 'help' || !option) {
|
|
101
|
+
console.log(getDescription(version));
|
|
102
|
+
program.help();
|
|
103
|
+
}
|
|
96
104
|
return (
|
|
97
105
|
shouldShowHelp(program, option) ||
|
|
98
106
|
((hasApplication() && options[option]) || showHelp(program))()
|
|
@@ -130,9 +138,9 @@ async function init() {
|
|
|
130
138
|
'-s, --sync',
|
|
131
139
|
'sync new instance-based src files to the ts directory'
|
|
132
140
|
);
|
|
141
|
+
program.option('-h, --help', 'display help for command');
|
|
133
142
|
program.usage(cyan('[options]'));
|
|
134
|
-
|
|
135
|
-
return doOptions(program);
|
|
143
|
+
return doOptions(program, version);
|
|
136
144
|
}
|
|
137
145
|
|
|
138
146
|
function introPrompt(msg: string) {
|