mirror of
https://github.com/balena-io/balena-cli.git
synced 2025-02-21 09:51:58 +00:00
Fix help command now that getMatchCommand() is async
This commit is contained in:
parent
1cf6d22d1b
commit
d3f91797bf
@ -82,39 +82,42 @@ exports.general = ->
|
|||||||
|
|
||||||
console.log()
|
console.log()
|
||||||
|
|
||||||
exports.command = (params) ->
|
exports.command = (params, options, done) ->
|
||||||
command = capitano.state.getMatchCommand(params.command)
|
capitano.state.getMatchCommand params.command, (error, command) ->
|
||||||
|
return done(error) if error?
|
||||||
|
|
||||||
if not command? or command.isWildcard()
|
if not command? or command.isWildcard()
|
||||||
return capitano.defaults.actions.commandNotFound(params.command)
|
return capitano.defaults.actions.commandNotFound(params.command)
|
||||||
|
|
||||||
console.log("Usage: #{command.signature}")
|
console.log("Usage: #{command.signature}")
|
||||||
|
|
||||||
if command.help?
|
if command.help?
|
||||||
console.log("\n#{command.help}")
|
console.log("\n#{command.help}")
|
||||||
else if command.description?
|
else if command.description?
|
||||||
console.log("\n#{_.str.humanize(command.description)}")
|
console.log("\n#{_.str.humanize(command.description)}")
|
||||||
|
|
||||||
if not _.isEmpty(command.options)
|
if not _.isEmpty(command.options)
|
||||||
console.log('\nOptions:\n')
|
console.log('\nOptions:\n')
|
||||||
|
|
||||||
options = _.map command.options, (option) ->
|
options = _.map command.options, (option) ->
|
||||||
option.signature = buildOptionSignatureHelp(option)
|
option.signature = buildOptionSignatureHelp(option)
|
||||||
return option
|
return option
|
||||||
|
|
||||||
optionSignatureMaxLength = _.max _.map options, (option) ->
|
optionSignatureMaxLength = _.max _.map options, (option) ->
|
||||||
return option.signature.toString().length
|
return option.signature.toString().length
|
||||||
|
|
||||||
for option in options
|
for option in options
|
||||||
console.log(getOptionHelp(option, optionSignatureMaxLength))
|
console.log(getOptionHelp(option, optionSignatureMaxLength))
|
||||||
|
|
||||||
console.log()
|
console.log()
|
||||||
|
|
||||||
|
return done()
|
||||||
|
|
||||||
exports.help =
|
exports.help =
|
||||||
signature: 'help [command...]'
|
signature: 'help [command...]'
|
||||||
description: 'show help'
|
description: 'show help'
|
||||||
action: (params) ->
|
action: (params, options, done) ->
|
||||||
if params.command?
|
if params.command?
|
||||||
exports.command(arguments...)
|
exports.command(params, options, done)
|
||||||
else
|
else
|
||||||
exports.general(arguments...)
|
exports.general(params, options, done)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user