kopia lustrzana https://gitlab.com/rysiekpl/libresilient
cli: bugfix — gracefully handling lack of "arguments" key in action object (ref. #66)
rodzic
035d5d8c4b
commit
3f95e786bc
11
cli/lrcli.js
11
cli/lrcli.js
|
@ -46,7 +46,12 @@ Options:
|
|||
|
||||
let printPluginActionUsage = (action, action_name) => {
|
||||
|
||||
// initialize
|
||||
let options = ""
|
||||
let positional = ""
|
||||
let positional_desc = ""
|
||||
|
||||
if ("arguments" in action) {
|
||||
for (const opt in action.arguments) {
|
||||
if (opt == '_') {
|
||||
continue
|
||||
|
@ -59,8 +64,6 @@ let printPluginActionUsage = (action, action_name) => {
|
|||
options += `\n`
|
||||
}
|
||||
|
||||
let positional = ''
|
||||
let positional_desc = ''
|
||||
if ('_' in action.arguments) {
|
||||
if ('name' in action.arguments._) {
|
||||
positional = ` <${action.arguments._.name}...>`
|
||||
|
@ -72,6 +75,7 @@ let printPluginActionUsage = (action, action_name) => {
|
|||
${positional}
|
||||
${action.arguments._.description}`
|
||||
}
|
||||
}
|
||||
|
||||
let usage = ` ${action_name}${ (options != "") ? " [options...]" : "" }${positional}
|
||||
${action.description}${positional_desc}
|
||||
|
@ -215,7 +219,8 @@ if (['--help', '-h'].includes(parsed_args._[2])) {
|
|||
var parsed_plugin_args = parsePluginActionArgs(
|
||||
// removing the plugin name and the method name
|
||||
parsed_args._.slice(2),
|
||||
plugin.actions[action].arguments
|
||||
// empty object in case arguments key does not exist
|
||||
plugin.actions[action].arguments || {}
|
||||
)
|
||||
|
||||
//console.log(parsed_plugin_args)
|
||||
|
|
Ładowanie…
Reference in New Issue