简体   繁体   中英

Naming convention for posix flags

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM