Socket
Book a DemoInstallSign in
Socket

inquander

Package Overview
Dependencies
Maintainers
2
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

inquander

Inquirer for commander. If no arguments and options are passed to your commander app, it runs inquirer.

latest
Source
npmnpm
Version
1.1.1
Version published
Maintainers
2
Created
Source

inquander

Inquirer for commander. This module takes two awesome modules and connects them.

If no arguments and options are passed to your commander app, it runs inquirer. For all commands, arguments and options defined in your commander app.

If you call your module with arguments it acts like a normal commander tool. call with arguments

But if you call it without any arguments or commands it will parse your definitions and runs it using inquirer. call without arguments

Usage

Instead of calling program.parse you need to call inquander.parse.

var program = require('commander'),
    inquander = require('inquander');

program
    .command('hello [name]')
    .action(function(name) {
        console.log('Hello', name);
    });
program
    .command('pay [creditcard]')
    .action(function(creditcard) {
        console.log('Please come again.');
        console.log(creditcard);
    });

inquander.parse(program, process.argv);

Options

Message and Default Command

The root message and default command options define the inquirer root behavior:

inquander.parse(program, process.argv, {
    message: 'Little Caesar\'s Pizza Ordering',
    defaultCommand: 'pay'
});

Type Overrides

The commander api doesn't identify special types (password, list, editor, etc). So to specify field types specifically for inquirer, use the overrides option:

inquander.parse(program, process.argv, {
    overrides: {
        'creditcard': {
            type: 'password'
        },
        'pickup': {
            type: 'checkbox',
            choices: ['one', 'two']
        }
    }
});

Hidden Fields

To hide a field from the interactive view, use the hidden option:

inquander.parse(program, process.argv, {
    hidden: ['notininquirer']
});
For more examples take a look into the example folder.

Advanced

Run Command

Inquander.runCommand(command, forceInteractive) allows you to manually trigger a generated command.

Detecting Interactive Mode

To enable different behavior for interactive and non-interactive modes, inquander defines a flag in program.usingInquirer which indicates whether inquander is using inquirer or commander.

Promises in Overrides

One can also pass Promises in for any value inside of the overrides object, for instance:

``Javascript inquander.parse(program, process.argv, { overrides: { 'creditcard': { type: 'password' }, 'pickup': { type: 'checkbox', choices: Promise.resolve(['one','two']) } } });

Keywords

inquirer

FAQs

Package last updated on 14 Jun 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts