Read more

Clean code: Avoiding short versions in command options

Emanuel
April 19, 2021Software engineer at makandra GmbH

This card is a general reminder to avoid the short version of a command option in shared code. It's much easier to understand a command and search for an option when it's written out.

Illustration UI/UX Design

UI/UX Design by makandra brand

We make sure that your target audience has the best possible experience with your digital product. You get:

  • Design tailored to your audience
  • Proven processes customized to your needs
  • An expert team of experienced designers
Read more Show archive.org snapshot

You can still use the short version of the options in your own terminal or in code snippets that are more useful when they are very compact. For the latter case you often see a description of the command options one line below e.g. in posts on stackoverflow.

Example good (in code):

/usr/bin/gpg --output password.txt --decrypt password.txt.gpg

Example good (when you want a short version for copy & paste e.g in a wiki):

/usr/bin/gpg -o password.txt -d password.txt.gpg
Encrypts a file with GPG (-o output file, -d decrypt file)

Example bad:

/usr/bin/gpg -o password.txt -d password.txt.gpg
Posted by Emanuel to makandra dev (2021-04-19 08:43)