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 online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
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)