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

自作多情 提交于 2019-12-08 06:11:32

问题


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!


回答1:


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.



来源:https://stackoverflow.com/questions/26259276/npm-questions-about-the-arguments-of-the-command-lines-of-installed-node-modul

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!