Questions tagged [yargs]

Yargs is a node.js package that helps you build interactive command line tools, by parsing arguments and generating an elegant user interface. Use this tag for questions relating to the Yargs node.js library.

143 questions
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
  • 13,139
  • 23
  • 99
  • 171
1
vote
0 answers

Yargs Module: Not enough arguments provided. Expected 1 but recieved 0

I am following a tutorial to learn nodeJS. We are creating commands using the Yargs module in a file named app.js. So far everything has worked perfectly until the tutorial requested I change some code at the end of my app.js file. Then I started to…
learnbasic
  • 35
  • 8
1
vote
1 answer

How to fix "SyntaxError: Expected "#", "\n", "\r" or [ \t] but "[" found." which is retrieved by yargs module?

I'm currently doing continuous deployment with bitbucket pipelines. I've put in a pipe the "npm test" command because I use mocha to do unit tests on my node project. When I run "npm test" on my local shell to test my routes, each of them works. But…
Joffrey
  • 21
  • 7
1
vote
3 answers

Terminal does not show yargs' handler value

I am learning node.js and I have first problem. After I have installed yargs and I am trying to create yargs command but it does not show in the terminal. When I type node app.js mycommand in terminal it only returns me the array of args, not my…
kaziutus
  • 138
  • 3
  • 10
1
vote
2 answers

command is not adding using yarg npm package

I am trying to add a command using yarg, but when I run my code my command is not added. Here is what I am trying: const yargs = require('yargs') //create add command yargs.command({ command: 'add', describe: 'to add note', handler:…
1
vote
1 answer

How do I unit test that an application using yargs provides the proper responses in multiple locales/languages?

I am working on a command line application that uses yargs to process options passed to that application and operates in a variety of languages. Testing fails when using non English locales because the expected results for the test are hard coded in…
1
vote
1 answer

Passing key value arguments from npm

So I'm struggling with passing command line option arguments from npm to a node script. I can pass options themselves, but not as key value pairs. For my package.json I have: "scripts": { "test": ". ./.env; node app.js --" }, (my understanding…
Huckleberry Carignan
  • 2,002
  • 4
  • 17
  • 33
1
vote
0 answers

How to detect if script is being called directly or via node with yargs?

I am writing a CLI utility in NodeJS using yargs. Yargs has an .usage() function that I use as follows: yargs.usage("\nUsage: node $0 --input=path/to/input/file --output=path/to/output/file") When I run node cli.js --help, it displays the…
Pedro A
  • 3,989
  • 3
  • 32
  • 56
1
vote
1 answer

Yargs .check() for specific conditions

I currently have yargs working in an app that can run with no arguments, or EITHER or BOTH of the following: a '-o' option with exactly one argument a '-f' option with no arguments These work, but nothing stops the user entering extra options or…
BruceM
  • 1,549
  • 1
  • 18
  • 41
1
vote
0 answers

how to get my parameters using yargs

I start my koa app with yarn: yarn start --some=123 The content of package.json is: "start": "cross-env NODE_ENV=develop nodemon --watch src --exec npm run start:babel -L", My file structure: package.json src -- main.js -- config.js --…
xinlei si
  • 11
  • 4
1
vote
1 answer

Separating/combining gulp task sources using yargs and gulp-if

Lets say I want to include all js files in a source folder concatenated in a specific order (using gulp-concat). However, I want to only include certain files if there is a production flag. For example, in production I need these…
hisnameisjimmy
  • 1,508
  • 2
  • 17
  • 24
1
vote
1 answer

yargs - require function is used in a way in which dependencies cannot be statically extracted

I am attempting to develop a module for a project I am working on. After splitting some core code into a separate directory and attempting to include the module with import Noxel from 'noxel' I am presented with a slew of…
NoxelNyx
  • 995
  • 1
  • 7
  • 21
1
vote
1 answer

Running script from Heroku CLI

I have a script that I want to run through the Heroku CLI. It's just a simple script to create a user in a postgressql database with Sequelize. This is the script: const argv = require('yargs').argv; const Sequelize = require('sequelize'); const…
Roi
  • 983
  • 9
  • 17
1
vote
1 answer

customizing positional command arguments with yargs

I am trying to use yargs for a command line application and I have run into a problem with my positional arguments. I have: require('yargs') .command( 'my-command ', 'This command does someting' (y) => { …
tkarls
  • 3,171
  • 3
  • 27
  • 27
1
vote
1 answer

How to call global env variable for gulp protractor

This is gulpfile: gulp.task( 'protractor', function () { var configObj = { configFile: config.test + 'protractor.conf.js' }; configObj['args'] =[];//to be able to add multiple parameters if…
mark
  • 727
  • 3
  • 14
  • 35