Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allows a handling function to be associated with a command #157

Merged
merged 4 commits into from
May 10, 2015

Conversation

bcoe
Copy link
Member

@bcoe bcoe commented May 4, 2015

allows a handling function to be associated with a command see #156

you can now optionally provide a third argument to command, which represents a handler for the function.

This command will get an instance of yargs passed into it, which can then be used to parse arguments specific to the command:

        yargs(['snuh', '-h'])
          .command('blerg', 'handle blerg things', function (yargs) {
            yargs.command('snuh', 'snuh command')
              .help('h')
              .argv
          })
          .help('h')
          .argv

I found that I tend to write boiler-plate code for a lot of my command-line applications, for facilitating this functionality.

bcoe added a commit that referenced this pull request May 10, 2015
allows a handling function to be associated with a command
@bcoe bcoe merged commit ad99ad6 into master May 10, 2015
@bcoe bcoe deleted the command-yargs branch May 10, 2015 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant