Questions tagged [node-commander]

Commander is a popular command-line arguments parser for Node.js, available through npm. It supports both short and long ("Gnu-style") arguments, as well as subcommand ("git-style") arguments.

Commander is a popular command-line argument parser for Node.js, available through npm. It supports both short and long ("Gnu-style") arguments, as well as subcommand ("git-style") arguments.

55 questions
23
votes
3 answers

Node js commander args returns true instead the value

I want to create a script with node and node commander and when i try to grab the values of my args i get the value true instead the value itself. For example if i write this in terminal: node myfile.js -s somefile -d test var program =…
user4207046
14
votes
2 answers

create nodejs cli select/options menu

How do you create an arrow-key menu list? I'm looking for something like after entering in eslint init or create-react-app ? (see images below) ESlint yeoman Searching around to find ways to create a CLI, I found NodeJS to be an option…
9
votes
1 answer

commander.js : how to specify required cli argument

I'm using commander.js package for parsing command-line arguments: I'd like to make a flag non-optional, the API and tests in the git repo loosely mention making a flag required, but I usually need to be hit over the head with instructions. Is it…
asking
  • 1,345
  • 2
  • 11
  • 18
5
votes
1 answer

Node.js commander with optional+variadic arguments

I'm butting my head against a wall trying to get node's commander module to parse arguments the way I want. I'm looking to upload a list of files to a named database. There is a default database name, so the user shouldn't need to include a database…
Gershy
  • 5,378
  • 1
  • 27
  • 38
5
votes
1 answer

Commander.js display help when called with no commands

I'm using commander.js to write a simple node.js program that interacts with an API. All calls require the use of subcommands. For example: apicommand get Is called as follows: program .version('1.0.0') .command('get [accountId]') …
toddg
  • 2,733
  • 2
  • 15
  • 29
4
votes
2 answers

Use commander in typescript

I try to use commander in typescript and I could like to give a proper type to my cli. So I start with this code: import * as program from "commander"; const cli = program .version("1.0.0") .usage("[options]") .option("-d, --debug", "activate…
Louis Roché
  • 724
  • 5
  • 17
4
votes
2 answers

Nodejs program doesn't terminate

This program will not terminate in the console, I have to use Ctrl-C. Documentation does not give any clues. Tried various things such as Return but just can't get it to terminate, it just hangs in the console. The last thing in the console is 'now…
Nepomuk
  • 55
  • 5
2
votes
1 answer

ORA Spinner stops on CLI with Inquirer.js

Don't know what to title the question but I will try my best to convey in the rest of the question. I am developing a CLI which first prompt user for a few questions and clone a repository based on the answers. Example: Frontend Framework: [x] Vue […
2
votes
2 answers

NodeJS Commander structured subcommands

I am new to commander and I am trying to achieve a command tree like this: |- build | |- browser (+ options) | |- cordova (+ options) | |- no subcommands, just options |- config | |- create (+ options) Is it possible to split these…
Lehks
  • 1,230
  • 1
  • 9
  • 26
2
votes
1 answer

Command line interface with Node.js

I am creating command line interface by using node.js. It has login feature and after login, needs to show output based on user selection from list. Problem i'm facing is it exits from the node after first result. It's asking login again. It should…
iLaYa ツ
  • 3,767
  • 2
  • 26
  • 45
2
votes
1 answer

Commander.js collect multiple options always include default

I'm using commander.js to parse the command line args and I'm trying to collect an optional param that can appear multiple times and it always returns the options I set plus the default one. function collect (val, memo) { memo.push(val); …
borgespires
  • 135
  • 2
  • 10
1
vote
0 answers

webpack Error: Cannot find module 'commander'

I get an error when I run in the CLI ./node_modules/.bin/webpack index.js --mode=development Here's the error: node:internal/modules/cjs/loader:903 throw err; ^ Error: Cannot find module 'commander' Require stack: -…
1
vote
0 answers

Commands for Commander not returning data

I'm trying to build a node cli to keep an organized planner. I have 'locate' command that goes to the options for commands either 'find' or 'list', but no data is being shown even though the mongoose functions are working correctly. 'todo locate…
Tripiod8
  • 31
  • 5
1
vote
1 answer

passing string with spaces to node cli-parser

var minimist = require("minimist") const a = minimist(`executable --param "a b"`.split(' ')) console.log(a) https://runkit.com/embed/57837xcuv5v0 actual output: Object {_: ["executable", "b\""], param: "\"a"} expected output: Object {_:…
Stav Alfi
  • 10,681
  • 15
  • 74
  • 124
1
vote
1 answer

Get multiple command option using commander

I'm creating a CLI using Nodejs and commander and i need to implement an option/command like this. --create user --f-name="Kevin" I tried various options but could get it working #!/usr/bin/env node const program = require("commander"); function…
TRomesh
  • 3,786
  • 5
  • 38
  • 61
1
2 3 4