Interaction

Functions to enable interaction with the user.

Table of Contents


interaction::prompt_yes_no()

Prompt yes or no question to the user.

Arguments

  • $1 (string): The question to be prompted to the user.
  • $2 (string): default answer [yes/no] (optional).

Exit codes

  • 0: If user responds with yes.
  • 1: If user responds with no.
  • 2: Function missing arguments.

Example

interaction::prompt_yes_no "Are you sure to proceed" "yes"
#Output
Are you sure to proceed (y/n)? [y]

interaction::prompt_response()

Prompt question to the user.

Arguments

  • $1 (string): The question to be prompted to the user.
  • $2 (string): default answer (optional).

Exit codes

  • 0: If user responds with answer.
  • 2: Function missing arguments.

Output on stdout

  • User entered answer to the question.

Example

interaction::prompt_response "Choose directory to install" "/home/path"
#Output
Choose directory to install? [/home/path]