Home

Awesome

Bash boilerplate

Features

Functions

Print functions

Misc helpers

Interactive mode

With this script comes a wtfmagic interactive mode which prompts the user to enter variables through stdin instead of the command line.

  1. This works by first defining which variables should be prompted for in the $interactive_opts variable.

  2. Making sure usage outputs valid information, where an options longname (eg. --password) has the same name as the variable in interactive_opts.

  3. Once the script has parsed all variables supplied through the command line, it will iterate through the interactive_opts array and parse the usage file for the description (also supports multiline).

  4. Now the user will be prompted and can enter the value through stdin. Note, if the variable is named password, interactive mode will automatically hide the input from prying eyes.

Once a script has many CLI options it becomes annoying to remember them all and this is when interactive mode shines. You can support both the scriptable CLI as well as a user friendly alternative for that one time per year when you actually need the script.

Acknowledgment