node.jscommand-linenpmcommand-line-argumentsdredd

npm - Questions about the arguments of the command lines of installed node modules


This question might not be related to npm specifically, but more about command lines in general.

I have installed Dredd (https://github.com/apiaryio/dredd) and I am trying to execute a command that needs to look like this:

dredd <path to blueprint> <api_endpoint> [OPTIONS]
  1. Do the first two arguments need to be strings (wrapped with quotes)?
  2. If I want to pass an output option with -o (or --output), Dredd specifies it needs to be an array. How do I pass an array in command line?

I have tried running

dredd services/address.md http://example.com -c false

I can see the command running, which tells me that the first two arguments don't necessarily need to be strings (I also tried with strings and it still works...), but the color option that is -c is suppose to disable the colors in the console when set to false, but it doesn't, so I'm probably calling the options wrong. Every option I try has no effect.

Hopefully you can help me!


Solution

  • Handling of CLI arguments is very implementation specific for each npm, so there is no general rule. There are many libraries to help create command-line tools for example commander or optimist. For specific behaviour please refer to these packages.

    But in this case it might be a bug. It does not work for me neither. Even if I change default for color output to true directly in the source-code of Dredd package. I filed an issue about that.