my_wins 1.3.2 → 1.3.3
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/lib/index.js +19 -3
- package/package.json +1 -1
- package/readme.md +8 -0
package/lib/index.js
CHANGED
|
@@ -45,6 +45,7 @@ function awaitDelay(delay) {
|
|
|
45
45
|
function parseArgs(argv) {
|
|
46
46
|
const raw = argv.slice(2);
|
|
47
47
|
let menu = false;
|
|
48
|
+
let version = false;
|
|
48
49
|
let runName;
|
|
49
50
|
const positional = [];
|
|
50
51
|
for (let i = 0; i < raw.length; i++) {
|
|
@@ -62,10 +63,15 @@ function parseArgs(argv) {
|
|
|
62
63
|
runName = arg.slice("--run=".length);
|
|
63
64
|
continue;
|
|
64
65
|
}
|
|
66
|
+
if (arg === "-v" || arg === "--version") {
|
|
67
|
+
version = true;
|
|
68
|
+
continue;
|
|
69
|
+
}
|
|
65
70
|
positional.push(arg);
|
|
66
71
|
}
|
|
67
72
|
return {
|
|
68
73
|
menu,
|
|
74
|
+
version,
|
|
69
75
|
single: runName || positional[0],
|
|
70
76
|
};
|
|
71
77
|
}
|
|
@@ -239,7 +245,11 @@ async function runOnce(baseSettings, filterNames) {
|
|
|
239
245
|
async function promptMenu(winNames) {
|
|
240
246
|
const choices = winNames.map((name)=>({ name, value: name }));
|
|
241
247
|
choices.push({ name: "exit", value: "__exit__", checked: true });
|
|
242
|
-
const
|
|
248
|
+
const prompt = inquirer.prompt || (inquirer.default && inquirer.default.prompt);
|
|
249
|
+
if (!prompt) {
|
|
250
|
+
throw new Error("Inquirer prompt API is unavailable. Please use a compatible inquirer version.");
|
|
251
|
+
}
|
|
252
|
+
const { selections } = await prompt([
|
|
243
253
|
{
|
|
244
254
|
type: "checkbox",
|
|
245
255
|
name: "selections",
|
|
@@ -252,12 +262,18 @@ async function promptMenu(winNames) {
|
|
|
252
262
|
|
|
253
263
|
module.exports.defaultSettings = defaultSettings;
|
|
254
264
|
module.exports.run = async ()=>{
|
|
255
|
-
|
|
265
|
+
const args = parseArgs(process.argv);
|
|
266
|
+
if (args.version) {
|
|
267
|
+
const pkgPath = require("path").join(__dirname, "..", "package.json");
|
|
268
|
+
const pkg = JSON.parse(fs.readFileSync(pkgPath));
|
|
269
|
+
console.log(pkg.version || "0.0.0");
|
|
270
|
+
process.exit(0);
|
|
271
|
+
}
|
|
256
272
|
|
|
257
273
|
const settings = loadSettings();
|
|
258
274
|
if (!settings) return;
|
|
259
275
|
|
|
260
|
-
|
|
276
|
+
console.log("Screen size:", keysender.getScreenSize());
|
|
261
277
|
const winNames = Object.keys(settings.wins || {});
|
|
262
278
|
|
|
263
279
|
if (args.menu) {
|
package/package.json
CHANGED
package/readme.md
CHANGED
|
@@ -87,6 +87,14 @@ Run a single win by name:
|
|
|
87
87
|
my_wins --run cmd1
|
|
88
88
|
```
|
|
89
89
|
|
|
90
|
+
### Version
|
|
91
|
+
|
|
92
|
+
Print current version:
|
|
93
|
+
|
|
94
|
+
```shell
|
|
95
|
+
my_wins --version
|
|
96
|
+
```
|
|
97
|
+
|
|
90
98
|
### All options
|
|
91
99
|
|
|
92
100
|
You can also create "my_wins_personal.json" which can partially or fully overrides my_wins.
|