Skip to main content

Logical

Commands guide users through tasks logically and intuitively to remove doubt.

Arguments and flags

  • Try to use flags instead of arguments
  • Boolean flags must default to false and be set to true when present
  • If the default of a boolean flag is true, use the prefix no- to flip the default

Arguments and flags 1 - Do

Arguments and flags 1 - Don't

  • Abbreviated flags are only used for frequent use cases
  • Abbreviated flags must have full length versions
  • Always use standard flag names when available
  • Defaults must match the most common use case and follow the principle of least astonishment (POLA)

Arguments and flags 2 - Do

Arguments and flags 2 - Don't

Arguments and flags 3 - Do

Arguments and flags 3 - Don't

  • Avoid creating order-dependent commands

Arguments and flags 4 - Do

Arguments and flags 4 - Don't

  • Ask for confirmation before executing long-lasting operations or unrecoverable actions
  • Clearly state consequential actions
  • Offer flags to bypass confirmation dialogs, e.g. -f / --force

Arguments and flags 5 - Do

Arguments and flags 5 - Don't

  • Never expose confidential information inside the CLI
  • Use a prompt or read from a file to prevent exposing confidential information

Arguments and flags 6 - Do

Arguments and flags 6 - Don't

Naming

Use names that are:

  • memorable
  • logical
  • short
  • simple
  • specific
  • guessable
  • lower case (small letters)
  • without spacing
  • without punctuation
  • without special characters
  • written in full (no abbreviations or aconyms unless unique)

Naming - Do

Naming - Don't