๐Ÿ“‚ interactive

โšก interactive::askForConfirmation

Ask the user to press the button to continue.

Inputs:

  • $1: prompt as string:

    the prompt to display

Returns:

  • $?:
    • 0 if the user pressed enter
    • 1 otherwise

Example usage:

interactive::askForConfirmation "Press enter to continue."

โšก interactive::askForConfirmationRaw

Ask the user to press the button to continue.

This raw version does not display the prompt or the answer.

Returns:

  • $?:
    • 0 if the user pressed enter
    • 1 otherwise

Example usage:

interactive::askForConfirmationRaw

โšก interactive::displayAnswer

Displays an answer to a previous question.

The text is wrapped and put inside a box like so:

    โ•ญโ”€โ”€โ”€โ”€โ”€โ•ฎ
    โ”‚ No. โ”œโ”€โ”€โ–‘
    โ•ฐโ”€โ”€โ”€โ”€โ”€โ•ฏ

Inputs:

  • $1: answer as string:

    the answer to display

  • ${width} as int:

    (optional) the maximum width of the text in the dialog box

    (defaults to “${GLOBAL_COLUMNS}”)

Example usage:

interactive::displayAnswer "My answer."

โšก interactive::displayQuestion

Displays a question to the user.

The text is wrapped and put inside a box like so:

   โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
โ–‘โ”€โ”€โ”ค Is this an important question? โ”‚
   โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ

Inputs:

  • $1: prompt as string:

    the prompt to display

  • ${width} as int:

    (optional) the maximum width of the text in the dialog box

    (defaults to “${GLOBAL_COLUMNS}”)

Example usage:

interactive::displayPrompt "Do you want to continue?"

โšก interactive::promptYesNo

Ask the user to yes or no.

  • The user can switch between the two options with the arrow keys or space.
  • The user can validate the choice with the enter key.
  • The user can also validate immediately with the y or n key.

Dialog boxes are displayed for the question and answer.

Inputs:

  • $1: prompt as string:

    the prompt to display

  • ${default} as bool:

    (optional) the default value to select

    (defaults to true)

Returns:

  • $?:
    • 0 if the user answered yes
    • 1 otherwise
  • ${REPLY}: true or false.

Example usage:

if interactive::promptYesNo "Do you want to continue?"; then echo "Yes."; else echo "No."; fi

โšก interactive::promptYesNoRaw

Ask the user to yes or no.

  • The user can switch between the two options with the arrow keys or space.
  • The user can validate the choice with the enter key.
  • The user can also validate immediately with the y or n key.

This raw version does not display the prompt or the answer.

Inputs:

  • ${default} as bool:

    (optional) the default value to select

    (defaults to true)

Returns:

  • $?:
    • 0 if the user answered yes
    • 1 otherwise
  • ${REPLY}: true or false.

Example usage:

interactive::promptYesNoRaw "Do you want to continue?" && local answer="${REPLY}"

Important

Documentation generated for the version 0.33.0 (2025-08-31).