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.
Questions tagged [yargs]
143 questions
1
vote
1 answer
Using yargs in *one* gulp task applies it in *all* tasks: Why? How to fix?
I've got a UI project, with an automation workflow based on generator-gulp-angular. I added gulp-ng-config, in order to perform builds differently based on an environment variable. I use the package 'yargs' to extract the environment flag, and make…

XML
- 19,206
- 9
- 64
- 65
0
votes
0 answers
How to make Yargs display examples in command specific "help"?
Typing -h prints normal help and I can add examples using the .example() API.
However, this is not printed when displaying help for a command:
myApp foobar -h
or
myApp foobar help
I would like to print examples for the command "foobar"…

user2297996
- 1,382
- 3
- 18
- 28
0
votes
1 answer
"yargs" won't trigger any command of a script
I have a NodeJs script in which I need parse command line arguments.
I've written this code:
import yargs from "yargs";
import { hideBin } from 'yargs/helpers';
//....
yargs(hideBin(process.argv)).command('--add-item ', 'desc',…

Marco C. Stewart
- 133
- 7
0
votes
0 answers
What is the right way to use a handler in a CommandModule
I have been using the handler to, you know, do the thing, whatever it is.
yargs(process.argv.slice(2))
.strict()
.demandCommand(1, "Please select a command\n")
.command({
command: "setup ",
handler: ({ token }) => {
…

Michael Lorton
- 43,060
- 26
- 103
- 144
0
votes
0 answers
when I am using import chalk from chalk then yargs is not working
when i am using
const yargs = require('yargs')
then it is not working for chalk
and when i am using import chalk from chalk then it is working for chalk but showing error for yargs

Nitin Pandey
- 11
0
votes
0 answers
Print the jest coverage table using exec via script
I am trying to create a utility to take the windows relative path from VSCode or IntelliJ and replace the forward slash from the path with backslash and execute the jest command to produce the coverage of the files mentioned in the argument to a…

Mandy8055
- 148
- 6
0
votes
0 answers
Set Yargs argument values programmatically
I have an application which can be invoked from console and programmatically as well. I have defined my command line arguments using yargs. How do I set the same args programmatically? and use their default values, incase they are not passed?
The…

Mahima
- 178
- 8
0
votes
1 answer
How do i extract arguments using yargs?
I'm using yargs lib in project. Importing it like this:
import { argv } from 'yargs';
Accessing all of args as following:
console.log('!!! start work', argv);
which gives the output smth like this:
!!! start work {
_: [
...list of args…

Aleksei Yerokhin
- 1
- 1
0
votes
0 answers
Best practice for storing token/credential using cli tools
I want to make cli tools just like firebase or github using yargs. so firebase does have this command "firebase login". I wonder how and where do they store the token/credential. If it's web browser I could store it in the cookie or local storage…

Patrick
- 734
- 11
- 26
0
votes
0 answers
Yargs help not display properly while --h is working
In my CLI when I call node cli.js --help I get this:
Options:
--help Show help [boolean]
--version Show version number [boolean]
However, when I call…

Chris
- 704
- 1
- 11
- 32
0
votes
1 answer
Error when integrating Wetty with a ReactJS project
I am trying to integrate Wetty API with a simple ReactJS project. I first ran into the shebang error.
ERROR in ./node_modules/wetty/build/main.js 1:0
Module parse failed: Unexpected character '#' (1:0)
File was processed with these loaders:
*…

WatchfulGuardian
- 61
- 4
0
votes
0 answers
yargs show main help after parse
I have the following code
const yargs = require("yargs");
const parser = yargs.command("test", "description", (yargs) => {
yargs.version("1.0.0");
});
yargs.command("test2", "description2", (yargs) => {
…

popcorn
- 9
- 3
0
votes
1 answer
How do I pass parameters to an NPM script that uses nodenv?
I have a NodeJS app that uses the NPM package node-env-run (i.e. to load environment variables from .env file). The package.json, I have a script that looks like this:
"scripts": {
"run-jobs": "nodenv tests/run-jobs.js"
}
Sometimes when I run…

Raphi OKG
- 73
- 5
0
votes
0 answers
Yargs throwing an error when trying to access argv members
I have
import * as yargs from 'yargs'
let args = yargs
.option('address', {
alias: 'a',
description: "address",
demand: true,
type: "string"
})
.option('network', {
alias: 'n',
…

kuco 23
- 786
- 5
- 18
0
votes
1 answer
What is the typed output of the Yarg() function?
I've been making a CLI and i needed yargs for parsing my arguments in a nice way. I am using typescript and i don't know the output of this Function, didn't find it anywhere as well:
const argv = Yargs(hideBin(process.argv))
.command('serve',…

jauki
- 73
- 6