by

Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    Jordan Harband
    @ljharb
    demandOption?
    or required: true probably
    Iliyan Peychev
    @ipeychev
    but I want only one to be required at time, not both
    either add or rm
    Jordan Harband
    @ljharb
    i think you want to then have two commands - remote add and remote rm
    and then .demandCommand
    Iliyan Peychev
    @ipeychev
    hm, so to create two commans, called remote add and remote rm? Doesn't yargs support kinda sub-commands?
    I thought "positionals" are the closest one to this concept
    Jordan Harband
    @ljharb
    i'm not sure how to require only one of those two tho, as subcommands
    Iliyan Peychev
    @ipeychev
    hm, I can't believe this is not possible with yargs. A good example would be git remote --help - there are many sub-commands plus additional params for each of them
    this is what I want to achieve
    like:
    git remote rename <old> <new>
    git remote remove <name>
    Jordan Harband
    @ljharb
    i mean that is in the examples
    Iliyan Peychev
    @ipeychev
    interesting, I'll check this. this thing with merging separate files I'm not sure I like very much on first sight (I hate magic), but I'll try to see of I'll build something based on that
    thanks!
    Míla Kuchta
    @kuchta

    Hi guys,

    I have a problem no other command line parsing library I've explored (probably) supports and since the generality of yargs, maybe you have some solution for it, but I can't really tell as from many options you provide, I'm a bit lost :).

    I want to get a list of possibly multiple commands with arguments in a row as defined on the command line, so that I can build from it a "functional pipeline", that will be applied to some array/iterator/stream.

    Is this case somehow solvable with yargs?

    Many thanks...

    Syed Faraaz Ahmad
    @faraazahmad
    what does the nargs() function do?
    I looked at the docs, and I dont understand it
    an example or 2 would be really helplful
    ClimbFlyCamp
    @ClimbFlyCamp

    Had a quick question. I am building a CLI using yargs and want to give users the options to add their own commands in a specific folder. I know I can use the following to accomplish this:

    .commandDir(path.join(process.cwd(), 'commands))

    This works great when the folder exists in the project, but if it does exist I get the following error:

    Error: Error: ENOENT: no such file or directory, scandir 'DIRECTORY_PATH'

    is there a way add the command directory ONLY if the directory exists?

    Joel Kirchartz
    @JKirchartz
    hey, I'm trying to use commandDir here in /bin to load commands from /lib but it seems the positional arguments only work for the first command and not the other ones? am I doing something wrong? https://github.com/jkirchartz/pos2tracery
    Plastikfan
    @plastikfan
    Hi, I'm having trouble writing typescript yargs unit tests. Can anyone help with this issue: https://stackoverflow.com/questions/60038269/how-to-correctly-unit-test-yargs-in-typescript,
    thanks.
    Leroy van Engelen
    @lvanengelen
    Hi, I am wondering whether yargs supports command lines as the following: myprog -r repo -v clone -p proj -a, i.e. having arguments (-r, -v) that are available for each command and are specified before it and arguments that are only valid for a specific command (-p, -a). Similar to https://git-scm.com/docs/git. I tried using something like yargs.option(...).command(...) but that did not seem to work.
    Leroy van Engelen
    @lvanengelen
    To clarify: In the example clone is a command, not an argument to -v. Only now seeing how unclear that was sigh
    Christopher Dieringer
    @cdaringe
    Hey all. Is there a known working recipe for nested completions? Suppose I have cmd a [a1, a2,a3]. When I punch in subsequently cmd a a1 I continue to get completions as a1 a2 a3 even if I did a .completion(a1, ...) with higher specificity options
    Joe Gornick
    @jgornick
    Hey folks, if writing CLIs with yargs, is there a recommended way to do any sort of logging? Is it just a matter of use npm/debug, or npm/winston?
    Martin Oppitz
    @martinoppitz
    Hello together
    I have detect a vulnerability in https://snyk.io/test/npm/yargs-unparser/1.6.0
    I would like to help you.
    Mikkel Høgh
    @mikl
    Is it just me, or is http://yargs.js.org/docs/ missing its content?
    https://raw.githubusercontent.com/yargs/yargs/v15.4.1/docs/api.md returns 404 for me