The dialog Snapcraft part: Support presenting TUI dialogs to the users

This Snapcraft part definition ships the dialog package to the snap, allowing packagers to present TUI dialogs to the users.

This is normally used in CLI snaps to present a message or require user input in a relatively friendly user interface:

Also, see Inform users with custom dialogs.

Prerequisites

This section documents the prerequisites for using this Snapcraft part:

Usage

This section documents the instructions on how to make use of this Snapcraft part:

  1. Merge the following part definition into the parts stanza of your snapcraft.yaml file:

    parts:
      # This snapcraft part allows the creation of TUI dialogs
      # https://forum.snapcraft.io/t/the-dialog-snapcraft-part-support-presenting-tui-dialogs-to-the-users/40145
      dialog:
        plugin: nil
        stage-packages:
          - dialog
        prime:
          # C header files
          - -usr/include
          # Static libraries(no dynamic libraries shipped in this
          # part
          - -usr/lib
          # Documentation(aside from the copyright declarations)
          - -usr/share/doc/dialog/README*
          - -usr/share/doc/dialog/changelog.*
          - -usr/share/doc/dialog/examples
          # Manual pages
          - -usr/share/man
          # Perl binding for Dialog
          - -usr/share/perl5
    
  2. In your launcher or other program, invoke the dialog utility as in the following example:

    dialog \
        --title 'Hello dialog(1) world' \
        --msgbox 'This is an example of the msgbox style dialog(1) dialog box' \
        0 0
    

    Refer to Ubuntu Manpage: dialog - display dialog boxes from shell scripts for more info on how to invoke the dialog utility.

Reference

Ubuntu Manpage: dialog - display dialog boxes from shell scripts