Search code examples
node.jsbashdockerfileyargs

In this bash script, what does "-" mean? And how could one find out what it means?


Here's the script:

node /app/ganache-core.docker.cli.js — quiet \ — account=”0x873c254263b17925b686f971d7724267710895f1585bb0533db8e693a2af32ff,100000000000000000000" \ — account=”0x8c0ba8fece2e596a9acfc56c6c1bf57b6892df2cf136256dfcb49f6188d67940,100000000000000000000"

I've read What's the magic of "-" (a dash) in command-line parameters?. And I took away that it CAN mean standard input... if the authors of the bash program define it as such.
However, here (link to ganache-core.docker.cli.js github file), I cannot find how or where the author of ganache-core.docker.cli.js would have defined the dash ("-") as standard input. Can someone point that out as well?

Edit: I am looking for confirmation that the dashes do mean standard input for cli args, but more-so looking to understand, WHY they should be definitively be interpreted as stnin when according the linked question above it's only a convention.

Edit2: I suspect the CLI arg parsing library is yArgs


Solution

  • This command line is just badly formatted. You're reading into something that isn't there. Some Blog software author thought it was a smart idea to auto-reformat the article so that hyphens and such were long dashes and quotes were "smart", etc. In the end, somehow a space ended up after the dash, before the next parameter.

    For example, let's look at this:

    node /app/ganache-core.docker.cli.js — quiet
    

    Even if we assume that's a regular hyphen -, we know it's not supposed to have a space after it. It's supposed to be -quiet. And, if you have any doubt about this, you can read in the source code where this is defined:

    .option('q', {
      group: 'Other:',
      alias: 'quiet',
      describe: 'Run ganache quietly (no logs)',
      type: 'boolean',
      default: false
    })
    

    The same is true for -account.

    And I took away that it CAN mean standard input... if the authors of the bash program define it as such.

    Yes, that's correct. I don't know what this software does, but if it's reading from STDIN, it's not because you told it to on the command line. It's because that's what it does.