sfcode
An Online Competing and Development Environment
|
Yet another parser for command line options.
COA is a parser for command line options that aim to get maximum profit from formalization your program API. Once you write definition in terms of commands, options and arguments you automaticaly get:
Command is a top level entity. Commands may have options and arguments.
Returns object containing all its subcommands as methods to use from other programs.
Set a canonical command identifier to be used anywhere in the API.
</strong> | String _name command name |
this
instance (for chainability)Set a long description for command to be used anywhere in text messages.
</strong> | String _title command title |
this
instance (for chainability)Create new or add existing subcommand for current command.
</strong> | COA.Cmd [cmd] existing command instance |
Create option for current command.
new
option instanceCreate argument for current command.
new
argument instanceAdd (or set) action for current command.
</strong> | Function act action function, invoked in the context of command instance and has the parameters:
|
</strong> | *{Boolean}* [force=false] flag for set action instead add to existings |
this
instance (for chainability)Apply function with arguments in context of command instance.
</strong> | Function fn |
</strong> | Array args |
this
instance (for chainability)Set custom additional completion for current command.
</strong> | Function fn completion generation function, invoked in the context of command instance. Accepts parameters:
|
this
instance (for chainability)Make command "helpful", i.e. add -h –help flags for print usage.
this
instance (for chainability)Adds shell completion to command, adds "completion" subcommand, that makes all the magic.
Must be called only on root command.
this
instance (for chainability)Build full usage text for current command instance.
usage
textParse arguments from simple format like NodeJS process.argv and run ahead current program, i.e. call process.exit when all actions done.
</strong> | Array argv |
this
instance (for chainability)Invoke specified (or current) command using provided options and arguments.
</strong> | String|Array cmds subcommand to invoke (optional) |
</strong> | Object opts command options (optional) |
</strong> | Object args command arguments (optional) |
Return reject of actions results promise.
Use in .act() for return with error.
</strong> | Object reason reject reasonYou can customize toString() method and exitCode property of reason object. |
Finish chain for current subcommand and return parent command instance.
parent
commandOption is a named entity. Options may have short and long keys for use from command line.