mythix-cli 1.3.5 → 1.3.7
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/runner.js +14 -15
- package/package.json +1 -1
package/bin/runner.js
CHANGED
|
@@ -203,7 +203,7 @@ async function initApplication(args) {
|
|
|
203
203
|
}
|
|
204
204
|
}
|
|
205
205
|
|
|
206
|
-
function generateCommandHelp(commandsObj, globalHelp) {
|
|
206
|
+
async function generateCommandHelp(application, commandsObj, globalHelp) {
|
|
207
207
|
let commandNames = Object.keys(commandsObj || {});
|
|
208
208
|
for (let i = 0, il = commandNames.length; i < il; i++) {
|
|
209
209
|
let commandName = commandNames[i];
|
|
@@ -211,7 +211,7 @@ function generateCommandHelp(commandsObj, globalHelp) {
|
|
|
211
211
|
let help = null;
|
|
212
212
|
|
|
213
213
|
if (typeof Klass.commandArguments === 'function') {
|
|
214
|
-
let result = (Klass.commandArguments() || {});
|
|
214
|
+
let result = ((await Klass.commandArguments(application, 'help')) || {});
|
|
215
215
|
help = result.help;
|
|
216
216
|
}
|
|
217
217
|
|
|
@@ -230,7 +230,7 @@ function generateCommandHelp(commandsObj, globalHelp) {
|
|
|
230
230
|
}
|
|
231
231
|
}
|
|
232
232
|
|
|
233
|
-
function commandRunners(commandsObj, context, showHelp) {
|
|
233
|
+
async function commandRunners(application, commandsObj, context, showHelp) {
|
|
234
234
|
let commandNames = Object.keys(commandsObj);
|
|
235
235
|
|
|
236
236
|
for (let i = 0, il = commandNames.length; i < il; i++) {
|
|
@@ -239,16 +239,16 @@ function commandRunners(commandsObj, context, showHelp) {
|
|
|
239
239
|
let runner = null;
|
|
240
240
|
|
|
241
241
|
if (typeof Klass.commandArguments === 'function') {
|
|
242
|
-
let result = (Klass.commandArguments() || {});
|
|
242
|
+
let result = ((await Klass.commandArguments(application, 'runner')) || {});
|
|
243
243
|
runner = result.runner;
|
|
244
244
|
}
|
|
245
245
|
|
|
246
|
-
let result = context.match(commandName, ({ scope, store, fetch }, parserResult) => {
|
|
246
|
+
let result = await context.match(commandName, async ({ scope, store, fetch, showHelp }, parserResult) => {
|
|
247
247
|
store({ command: commandName });
|
|
248
248
|
|
|
249
|
-
return scope(commandName, (context) => {
|
|
249
|
+
return await scope(commandName, async (context) => {
|
|
250
250
|
if (typeof runner === 'function') {
|
|
251
|
-
let runnerResult = runner(context, parserResult);
|
|
251
|
+
let runnerResult = await runner(context, parserResult);
|
|
252
252
|
if (!runnerResult) {
|
|
253
253
|
showHelp(commandName);
|
|
254
254
|
return false;
|
|
@@ -354,13 +354,13 @@ function commandRunners(commandsObj, context, showHelp) {
|
|
|
354
354
|
try {
|
|
355
355
|
let helpShown = false;
|
|
356
356
|
|
|
357
|
-
const customShowHelp = (
|
|
357
|
+
const customShowHelp = (subHelp) => {
|
|
358
358
|
if (helpShown)
|
|
359
359
|
return;
|
|
360
360
|
|
|
361
361
|
helpShown = true;
|
|
362
362
|
|
|
363
|
-
showHelp(
|
|
363
|
+
showHelp(subHelp)
|
|
364
364
|
};
|
|
365
365
|
|
|
366
366
|
let rootOptions = { help, showHelp: customShowHelp, helpArgPattern: null };
|
|
@@ -377,11 +377,13 @@ function commandRunners(commandsObj, context, showHelp) {
|
|
|
377
377
|
let applicationOptions = application.getOptions();
|
|
378
378
|
|
|
379
379
|
let commands = await mythixCLI.loadCommands(applicationOptions.commandsPath);
|
|
380
|
-
generateCommandHelp(commands, help);
|
|
380
|
+
await generateCommandHelp(application, commands, help);
|
|
381
381
|
|
|
382
|
-
let commandContext = CMDed((context) => {
|
|
382
|
+
let commandContext = await CMDed(async (context) => {
|
|
383
383
|
let { $, Types, store } = context;
|
|
384
384
|
|
|
385
|
+
store('mythixApplication', application);
|
|
386
|
+
|
|
385
387
|
$('--config', Types.STRING({
|
|
386
388
|
format: Path.resolve,
|
|
387
389
|
})) || store({ config: (Nife.isNotEmpty(process.env.MYTHIX_CONFIG_PATH)) ? Path.resolve(process.env.MYTHIX_CONFIG_PATH) : Path.join(process.env.PWD, '.mythix-config.js') });
|
|
@@ -393,7 +395,7 @@ function commandRunners(commandsObj, context, showHelp) {
|
|
|
393
395
|
|
|
394
396
|
$('--help', Types.BOOLEAN());
|
|
395
397
|
|
|
396
|
-
return commandRunners(commands, context, customShowHelp);
|
|
398
|
+
return await commandRunners(application, commands, context, customShowHelp);
|
|
397
399
|
}, rootOptions);
|
|
398
400
|
|
|
399
401
|
if (!commandContext) {
|
|
@@ -413,7 +415,4 @@ function commandRunners(commandsObj, context, showHelp) {
|
|
|
413
415
|
} catch (error) {
|
|
414
416
|
console.error(error);
|
|
415
417
|
}
|
|
416
|
-
// rootCommand = SimpleYargs.buildCommands(rootCommand, initApplication, [ 'init(Create a new application with the given name) <appName:string(Specify application name)> [-d,-dir:string(Path at which to create application)] [-t,-template:string(Git URL to use to clone and create new project from)=https://github.com/th317erd/mythix-app-template.git(Default "https://github.com/th317erd/mythix-app-template.git")] [-tag:string(Specify tag or commit hash to clone template from)]' ]);
|
|
417
|
-
|
|
418
|
-
// rootCommand.version(packageJSON.version).strictCommands().wrap(120).parse();
|
|
419
418
|
})();
|