Skip to content

Show help if no command was executed #7

@ghost

Description

Hi

I wanted my utility to show help if no command was executed.

This was how I monkey patched my code to solve it.

parentAction = commander.Command::action
commander.Command::action = (fn) ->
    newFn = ->
        fn.apply this, arguments
        commander.commandExecuted = this
    parentAction.apply this, [newFn]

# later after parse statement
if !commander.commandExecuted?
    process.stdout.write commander.helpInformation()

Is this an acceptable solution, or is there something I'm missing in the API?

Chris

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions