Naming convention for posix flags
Asked Answered
R

1

6

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

Rugose answered 27/1, 2017 at 16:15 Comment(0)
E
10

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.

Eponymous answered 2/4, 2017 at 22:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.