posix标志的命名约定

时间:2017-01-27 16:15:48

标签: linux coding-style posix flags

我正在编写一个允许设置几个Posix标志的控制台应用程序。

这就是我目前正在使用的内容。标志中的单词用短划线连接:

  -p, --broker-port int     Broker Port (default 1883)
  -u, --broker-url string   Broker URL (default "localhost")
  -c, --client-id string    MQTT Client Id
  -r, --room string         Room where sensor is located (default "myroom")
  -f, --floor string        Floor, where room is located (default "basement")

但是我也看到过使用CamelCase连接pflags的应用程序。

官方GNU coding standard没有指定如何连接posix标志中的单词。

正确的方法是什么?

由于

1 个答案:

答案 0 :(得分:5)

答案似乎埋没在GNU docs here中。

  

GNU为这些约定添加了长选项。长选项包括   ' - '后跟一个由字母数字字符和破折号组成的名称。   选项名称通常为一到三个字长,连字符为   单词。用户可以缩写选项名称,只要   缩写是独一无二的。

你所遵循的惯例;骆驼案没有。

相关问题