Naming convention for posix flags

送分小仙女□ 提交于 2019-12-05 07:28:43

问题


I'm writing a console application which allows several Posix flags to be set.

This is what I'm using currently. Words in the flags are concatenated with a dash:

  -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")

However I have also seen applications using CamelCase to concatenate pflags.

The official GNU coding standard does not specify how to concatenate words in posix flags.

What is the right way?

Thanks


回答1:


The answer seems to be buried in the GNU docs here.

GNU adds long options to these conventions. Long options consist of ‘--’ followed by a name made of alphanumeric characters and dashes. Option names are typically one to three words long, with hyphens to separate words. Users can abbreviate the option names as long as the abbreviations are unique.

What you've got follows the convention; camel case does not.



来源:https://stackoverflow.com/questions/41898391/naming-convention-for-posix-flags

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