npm-有关已安装的节点模块的命令行参数的问题 [英] npm - Questions about the arguments of the command lines of installed node modules

查看:114
本文介绍了npm-有关已安装的节点模块的命令行参数的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题可能与npm无关,但更多地与命令行有关.

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

我已经安装了Dredd( https://github.com/apiaryio/dredd ),我是尝试执行需要如下所示的命令:

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. 前两个参数是否需要为字符串(用引号引起来)?
  2. 如果我想使用-o(或--output)传递输出选项,Dredd指定它必须是一个数组.如何在命令行中传递数组?

我尝试运行

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

我可以看到命令正在运行,它告诉我前两个参数不一定需要是字符串(我也尝试过使用字符串,它仍然可以工作...),但是-c的color选项是假设在设置为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.

希望您能帮助我!

推荐答案

CLI参数的处理非常具体地针对每个npm,因此没有通用规则.有许多库可帮助创建命令行工具,例如 commander

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.

但是在这种情况下,这可能是一个错误.这对我也不起作用.即使我直接在中将颜色输出的默认值更改为true Dredd包的源代码.我为此提交了问题.

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.

这篇关于npm-有关已安装的节点模块的命令行参数的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆