How to denote that a command line argument is optional when printing usage

后端 未结 3 1487
情书的邮戳
情书的邮戳 2021-01-30 02:18

Assume that I have a script that can be run in either of the following ways.

./foo arg1 arg2
./foo

Is there a generally accepted way to denote

3条回答
  •  清歌不尽
    2021-01-30 03:10

    I suppose this is as much a standard as anything.

    The Open Group Base Specifications Issue 7

    IEEE Std 1003.1, 2013 Edition

    Copyright © 2001-2013 The IEEE and The Open Group

    Ch. 12 - Utility Conventions

    Although it doesn't seem to mention many things I have commonly seen over the years used to denote various meanings:

    • square brackets [optional option]
    • angle brackets
    • curly braces {default values}
    • parenthesis (miscellaneous info)

    Edit: I should add, that these are just conventions. The important thing is to pick a convention which is sensible, clearly state your convention, and stick to it consistently. Be flexible and create conventions which seem to be most frequently encountered on your target platform(s). They will be the easiest for users to adapt to.

提交回复
热议问题