~skeeto/public-inbox

1

Examples of "optional option arguments"?

Ulysse Carion
Details
Message ID
<CAJK=1RjWbQsxJFpEzUDA59eo3VsTVSCUbtLTahu7TZhynmBjWA@mail.gmail.com>
DKIM signature
pass
Download raw message
Hi,

In "Conventions for Command Line Options", you describe "optional
option arguments". Can you give an example of a tool that supports
such an option? I'm struggling to see the use-case, and can't recall
ever having seen this in the wild.

Thanks,
Ulysse
Details
Message ID
<20200823171736.4253f3wticjzya2c@nullprogram.com>
In-Reply-To
<CAJK=1RjWbQsxJFpEzUDA59eo3VsTVSCUbtLTahu7TZhynmBjWA@mail.gmail.com> (view parent)
DKIM signature
missing
Download raw message
Half the various GNU utilities have at least one. Any that produce color 
output (ls, grep, etc.) have a --color option with an optional "WHEN" 
argument. ln, install, and mv have a --backup with optional CONTROL 
argument. df --output has an optional FIELD_LIST argument. mkdir, 
install, mkfifo, and mknod have --context with an optional CTX argument. 
ls and vdir have --hyperlink with an optional WHEN argument. mkdir 
--tmpdir has an optional DIR argument. rm has --interactive with an 
optional WHEN argument and --preserve-root with an optional ALL 
argument. sched has --remove with an optional HOW. od has --width with 
an optional BYTES, and it also comes with a short option version -w also 
taking optional BYTES. pr also has a whole bunch like this. I could keep 
going since GNU has so many examples, but I'll stop here!

Git has a ton of them, too. Its --exec-path option takes an optional 
path. The show command has --pretty, --notes, and --show-notes with 
optional arguments. The log command has --decorate, --branches, --tags, 
--remotes, --no-walk, --pretty, --notes, --show-notes, 
--show-linear-break, --stat, --dirstat, --submodule, --color, 
--color-moved, --word-diff, --color-words, --abbrev, --break-rewrites 
(and -B), --find-renames, --find-copies, --relative, and 
--ignore-submodules all taking optional arguments. Again, I could 
probably list a hundred more just by further exploring the man pages.

My own passphrase2pgp has --protect (-e), --expires (-x), and --pinentry 
each with an optional argument. My Enchive tool has --derive (-d) with 
an optional iteration count, as well as --pinentry and --agent.

https://github.com/skeeto/passphrase2pgp#usage
https://nullprogram.com/enchive/

Basically you need only grep "[=" in man pages to find them.
Reply to thread Export thread (mbox)