-
Notifications
You must be signed in to change notification settings - Fork 249
Add help for $ phenomic
and unknown commands
#757
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
import "babel-polyfill" | ||
import { join } from "path" | ||
import colors from "chalk" | ||
|
||
import setup from "./commands/setup/index.js" | ||
|
||
|
@@ -68,4 +69,29 @@ yargs.command( | |
runner | ||
) | ||
|
||
yargs.check((argv) => { | ||
// requires at least 1 argument | ||
// show help when type `$ phenomic` | ||
// argv._ = [ | ||
// nodePath, | ||
// pathToPhenomicScript, | ||
// input argvs | ||
// ] | ||
if (argv._.length < 3) { | ||
throw new Error( | ||
colors.bgRed(colors.white("ERROR")) + | ||
colors.red(" You must specify command for Phenomic CLI") | ||
) | ||
} | ||
|
||
// Unknown command | ||
const currentCommand = argv._[2] | ||
if ([ "start", "build", "setup" ].indexOf(currentCommand) < 0) { | ||
throw new Error( | ||
colors.bgRed(colors.white("ERROR")) + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should probably try to output a more fancy error prefix than "ERROR" :D There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @MoOx what are you suggesting? |
||
colors.red(` Unknown command "${ currentCommand }"`) | ||
) | ||
} | ||
}) | ||
|
||
yargs.parse(process.argv) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,8 @@ import definitions from "./definitions.js" | |
|
||
yargs | ||
.version(() => version) | ||
.help() | ||
.usage("Usage: phenomic <command> [options]") | ||
// .hep() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this thing not working? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not working at all since we don't any validations with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oups :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oops :D |
||
.showHelpOnFail() | ||
.epilogue( | ||
"For more information about the configuration, " + | ||
|
@@ -32,13 +33,6 @@ Object.keys(definitions).forEach((optName) => { | |
if (option.description) { | ||
yargs.describe(optName, option.description) | ||
} | ||
|
||
// made by hand for now, we might revisit option this later | ||
// if (validators[optName]) { | ||
// yargs.check(() => { | ||
// | ||
// }) | ||
// } | ||
}) | ||
|
||
export default yargs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you remove this commented code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK. I added this on purpose to explain about
argv._.length < 3