mirror of
https://github.com/balena-io/balena-cli.git
synced 2024-12-24 07:46:39 +00:00
Make run() print help if no matches
This commit is contained in:
parent
14459e1d09
commit
91567cb5c7
@ -5,6 +5,8 @@ config = require('./config')
|
||||
yargs = require('yargs')
|
||||
yargs.command = require('./yargs-command/yargs-command')
|
||||
|
||||
yargs.usage('$0 [options] <command>')
|
||||
|
||||
# ---------- Auth Module ----------
|
||||
auth = require('./actions/auth')
|
||||
|
||||
|
@ -26,6 +26,8 @@ commandApplies = (command, args) ->
|
||||
return true
|
||||
|
||||
run = ->
|
||||
if not @command._matchedCommand?
|
||||
return console.log(@help())
|
||||
signature = splitSignature(@command._matchedCommand.signature)
|
||||
parameters = _.difference(@argv._, signature)
|
||||
@command._matchedCommand.action.apply(this, parameters)
|
||||
|
@ -108,3 +108,8 @@ describe 'Yargs Command:', ->
|
||||
yargs.command(COMMANDS.appList.signature, callback)
|
||||
yargs.command.run()
|
||||
expect(callback).to.have.been.calledWith(_.last(ARGS.appList._))
|
||||
|
||||
it 'should print help if no matches', ->
|
||||
helpSpy = sinon.spy(yargs, 'help')
|
||||
yargs.command.run()
|
||||
expect(helpSpy).to.have.been.called
|
||||
|
Loading…
Reference in New Issue
Block a user