mythix-cli 1.3.3 → 1.3.5

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.
Files changed (2) hide show
  1. package/bin/runner.js +31 -7
  2. package/package.json +2 -2
package/bin/runner.js CHANGED
@@ -230,7 +230,7 @@ function generateCommandHelp(commandsObj, globalHelp) {
230
230
  }
231
231
  }
232
232
 
233
- function commandRunners(commandsObj, context) {
233
+ function commandRunners(commandsObj, context, showHelp) {
234
234
  let commandNames = Object.keys(commandsObj);
235
235
 
236
236
  for (let i = 0, il = commandNames.length; i < il; i++) {
@@ -243,12 +243,22 @@ function commandRunners(commandsObj, context) {
243
243
  runner = result.runner;
244
244
  }
245
245
 
246
- let result = context.match(commandName, ({ scope, store }, parserResult) => {
246
+ let result = context.match(commandName, ({ scope, store, fetch }, parserResult) => {
247
247
  store({ command: commandName });
248
248
 
249
249
  return scope(commandName, (context) => {
250
- if (typeof runner === 'function')
251
- return runner(context, parserResult);
250
+ if (typeof runner === 'function') {
251
+ let runnerResult = runner(context, parserResult);
252
+ if (!runnerResult) {
253
+ showHelp(commandName);
254
+ return false;
255
+ }
256
+ }
257
+
258
+ if (fetch('help', false)) {
259
+ showHelp(commandName);
260
+ return false;
261
+ }
252
262
 
253
263
  return true;
254
264
  });
@@ -342,8 +352,18 @@ function commandRunners(commandsObj, context) {
342
352
  }
343
353
 
344
354
  try {
345
- let rootOptions = { help };
355
+ let helpShown = false;
356
+
357
+ const customShowHelp = (scope) => {
358
+ if (helpShown)
359
+ return;
346
360
 
361
+ helpShown = true;
362
+
363
+ showHelp(help[scope] || help)
364
+ };
365
+
366
+ let rootOptions = { help, showHelp: customShowHelp, helpArgPattern: null };
347
367
  let mythixPath = Path.dirname(require.resolve('mythix', { paths: [ process.env.PWD, Path.resolve(process.env.PWD, 'node_modules') ] }));
348
368
  let mythixCLIPAth = Path.resolve(mythixPath, 'cli');
349
369
  let mythixCLI = require(mythixCLIPAth);
@@ -371,11 +391,15 @@ function commandRunners(commandsObj, context) {
371
391
  $('-e', Types.STRING(), { name: 'environment' });
372
392
  $('--env', Types.STRING(), { name: 'environment' });
373
393
 
374
- return commandRunners(commands, context);
394
+ $('--help', Types.BOOLEAN());
395
+
396
+ return commandRunners(commands, context, customShowHelp);
375
397
  }, rootOptions);
376
398
 
377
- if (!commandContext)
399
+ if (!commandContext) {
400
+ customShowHelp();
378
401
  return process.exit(1);
402
+ }
379
403
 
380
404
  await mythixCLI.executeCommand(
381
405
  config,
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "mythix-cli": "./bin/mythix-cli.js"
4
4
  },
5
5
  "name": "mythix-cli",
6
- "version": "1.3.3",
6
+ "version": "1.3.5",
7
7
  "description": "Mythix CLI utility",
8
8
  "main": "src/index.js",
9
9
  "scripts": {
@@ -30,7 +30,7 @@
30
30
  "mythix": "^2.4.14"
31
31
  },
32
32
  "dependencies": {
33
- "cmded": "^1.2.1",
33
+ "cmded": "^1.2.5",
34
34
  "nife": "^1.11.3"
35
35
  },
36
36
  "devDependencies": {