I am hearing these two terms interchangeably and I am wondering if there is any difference between them, like flags are for one letter options or flags are after a single dash.

  • I haven't seen any evidence to support either assertion below re: the "official" distinction between flag & option, which suggests that @Anthon's humble response to the same question over on unix.stackexchange might be more accurate, if less definitive: unix.stackexchange.com/questions/285575/…. – clozach May 7 '19 at 22:17

You'll probably find "arguments", "options", and "switches" are also often used interchangeably in this context as well.

"Flags" specifically, are Boolean arguments, set by the mere inclusion of the command-line argument, with no additional data needed or allowed for the argument. If you include the argument/option/flag, it counts as "true" and if you exclude it, it counts as "false".

Example Flag-type argument:

command.exe -DeleteFiles

Example of non-flag argument:

command.exe -ServerName my.server.com

More info

| improve this answer | |
  • Simple and effective explanation. You could probably even put that 2nd paragraph into the tag wiki for flag, since it has no description currently and that makes it a bit less ambiguous. – Broots Waymb Apr 26 '16 at 18:06

According to Build Awesome Command-Line Applications in Ruby 2 the main distinction is: a switch doesn't take arguments, while a flag does. Quoting directly from the book (page 15):

enter image description here

Typically, if a switch is in the long-form (for example --foo), which turns “on” some behavior, there is also another switch preceded with no- (for example --no-foo) that turns “off” the behavior.

Finally, long-form flags take their argument via an equal sign, whereas in the short form of a flag, an equal sign is typically not used. For example, the curl command, which makes HTTP requests, provides both short-form and long-form flags to specify an HTTP request method: -X and --request, respectively. The following example invocations show how to properly pass arguments to those flags:

curl -X POST http://www.google.com
curl --request=POST http://www.google.com
| improve this answer | |
  • out of curiosity: how would one call the "some string" part of the call? In a first shot I would say it's simply an "argument", but if so, how would one call all arguments including the switches/options/flags? Aren't all these things kind of "arguments"? How could they be distinguished by name? – jlang Mar 15 at 11:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.