4

I've been reading a bit about how programs handle command line parameters. But the information seems to be "incomplete", things I've read:

  • Options may have a preceding '-' or '/' sign if front of them.
  • Options can have additional arguments (which go without a - sign)
  • the option arguments follow the option directly, with or without a space.
  • Options can be a single letter or a full word.
  • optionscan be merged inside a single "option": -abc equals -a -b -c

(Source)

Now I'm really wondering: What kind of options do you give a "-" sign and which not. Also the merging of options into 1 seems to be incompatible with full-word options? "-file" can be a full word, but it might also mean "-f", "-i", "-l", "-e", 4 different switches. Or even: "-f" with "ile" as option_argument.

Am I understanding something wrong?

paul23
  • 8,799
  • 12
  • 66
  • 149

2 Answers2

4

On systems like Linux, there is the convention that options that are full words use two dashes (e.g. --file), while single-letter options use a single dash (e.g. -f.)

Using slash to introduce options is from old DOS, and is being kept in Windows.

Also, if an option is using a whole word, it can not be split into several options. This is in regards to your example with -file: -file can either be one option, or four different options (-f, -i, -l and -e).

All in all, how options looks, or is handled, differ very much between programs, and there really isn't any specific standard.

I would suggest you find some way you like, and then use that.

Some programmer dude
  • 400,186
  • 35
  • 402
  • 621
  • Agree with above, with the addition that you use the option convention for the OS you expect to support. Good luck. – shellter Oct 26 '11 at 15:39
  • Well, I'm hard pressed to find the option-convention for windows.. I haven't seen "//" or "--" much on windows. And I'm really wondering if combining options is actually ever done in windows. – paul23 Oct 26 '11 at 22:20
  • 1
    @paul23 Now that more people use Git-for-Windows, especially using Bash-on-Windows (either mingw32, mingw64, or Windows 10's Linux Subsystem) I'm seeing more Windows command-line programs adopt the convention. I also recommend using `-` and `--` instead of `/` for command-line flags in case you need to add Linux or DNX support to your program. – Dai Oct 16 '18 at 04:30
0

There are no Windows standards for options/arguments/parameters etc.

Options are developed as per the developers understanding to make it easy for them to interpret the passed in information.

The real reason for / or - prefixed options is generally for parsing rules since it's much easier to parse unique option prefixes with less code rather than complex options with large code. Common development standards (such as standard use options) minimises confusion for users ;)

MacG
  • 271
  • 2
  • 4