-
Notifications
You must be signed in to change notification settings - Fork 1
migrate #23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
migrate #23
Changes from 13 commits
af6a28d
d1eb2fe
9ca42ea
9f9ae0e
14b4a77
6cf51d7
627938b
65a0fe8
27f8879
292fad2
3c5049e
9c0fc08
a35e751
374e746
8e8c671
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| [info_box] | ||
| description=Display a rolling info box with dialog/whiptail; reads and shows lines from stdin or a single message. | ||
| extend_desc=This helper provides a live-updating infobox for progress or log output in TUI (dialog/whiptail). When piped, shows the last N lines as they arrive. If called with an argument, displays it as a static message. Useful for monitoring, user feedback, or background task reporting in config-v3. | ||
| documents=false | ||
| options=[message] | (via stdin/pipe) | ||
| parent=framework | ||
| group=helpers | ||
| contributor=Tearran | ||
| maintainer=true | ||
| arch=arm64 armhf x86-64 | ||
| require_os=Debian Ubuntu Armbian | ||
| require_kernel=5.15+ | ||
| port=false | ||
|
|
||
|
|
||
| [_about_info_box] | ||
| description=Display usage and about information for the info_box helper. | ||
| extend_desc=Provides concise usage instructions and example commands for the info_box module. Intended for internal and help display use only. | ||
| documents=false | ||
| options= | ||
| parent=framework | ||
| group=helpers | ||
| contributor=Tearran | ||
| maintainer=true | ||
| arch=arm64 armhf x86-64 | ||
| require_os=Debian Ubuntu Armbian | ||
| require_kernel=5.15+ | ||
| port=false |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,63 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| _about_info_box() { | ||
| cat <<EOF | ||
| Usage: info_box | ||
|
|
||
| Displays a rolling info box using dialog/whiptail. | ||
| Reads lines from stdin and displays them live. | ||
| If not used with a pipe, shows a single message. | ||
|
|
||
| Examples: | ||
| some_command | info_box | ||
| echo "Hello" | info_box | ||
| info_box -h|--help|help | ||
| EOF | ||
| } | ||
|
|
||
| info_box() { | ||
| # Help flag: show about if -h or --help is the first argument | ||
| case "${1:-}" in | ||
| -h|--help|help) | ||
| _about_info_box | ||
| return 0 | ||
| ;; | ||
| esac | ||
|
|
||
| local input | ||
| local dialog="${DIALOG:-}" | ||
| if [[ "$dialog" != "dialog" && "$dialog" != "whiptail" ]]; then | ||
| dialog="whiptail" | ||
| fi | ||
|
|
||
| # Ensure the binary exists | ||
| if ! command -v "$dialog" >/dev/null 2>&1; then | ||
| echo "Error: neither dialog nor whiptail found in \$PATH." >&2 | ||
| return 127 | ||
| fi | ||
|
|
||
| local title="${TITLE:-Info}" | ||
| local -a buffer | ||
| local lines="${LINES:-16}" width="${WIDTH:-90}" max_lines="${MAX_LINES:-18}" | ||
|
|
||
| if [ -p /dev/stdin ]; then | ||
| while IFS= read -r line; do | ||
| buffer+=("$line") | ||
| # Limit buffer size to max_lines | ||
| ((${#buffer[@]} > max_lines)) && buffer=("${buffer[@]:1}") | ||
| # Show buffer in infobox | ||
| TERM=ansi $dialog --title "$title" --infobox "$(printf "%s\n" "${buffer[@]}")" $lines $width | ||
| sleep 0.5 | ||
| done | ||
| else | ||
| input="${1:-}" | ||
| if [[ -z "$input" ]]; then | ||
| echo "Error: No input provided." >&2 | ||
| _about_info_box | ||
| return 1 | ||
| fi | ||
| TERM=ansi $dialog --title "$title" --infobox "$input" 6 80 | ||
| sleep 2 | ||
| fi | ||
| echo -ne '\033[3J' # put cursor at end | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| [ok_box] | ||
| feature=ok_box | ||
| description=Displays a message to the user using the configured dialog tool. | ||
| extend_desc=Reads input text (either from standard input or as an argument) and presents it to the user with the selected dialog frontend. Supports dialog, whiptail, or plain read/echo. Handles input flexibly and routes output appropriately depending on the tool. | ||
| extend_docs=false | ||
| options=<message> | ||
| parent=framework | ||
| group=helpers | ||
| contributor=Tearran | ||
| maintainer=true | ||
| arch=arm64 armhf x86-64 | ||
| require_os=Debian Ubuntu Armbian | ||
| require_kernel=5.15+ | ||
| port=false | ||
|
|
||
| [_about_ok_box] | ||
| feature=_about_ok_box | ||
| description=Show help and usage information for the ok_box helper. | ||
| extend_desc=Outputs usage, available options, and example commands for the interface_message helper function. | ||
| extend_docs=false | ||
| options= | ||
| parent=framework | ||
| group=helpers |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,53 @@ | ||||||
| #!/usr/bin/env bash | ||||||
|
|
||||||
|
|
||||||
| function _about_ok_box() { | ||||||
| cat <<EOF | ||||||
| Usage: ok_box ["message"] | ||||||
| Examples: | ||||||
| ok_box "Operation completed successfully." | ||||||
| echo "Hello from stdin" | ok_box | ||||||
| ok_box <<< "Message from here-string" | ||||||
| EOF | ||||||
|
|
||||||
| } | ||||||
|
|
||||||
| function ok_box() { | ||||||
|
|
||||||
| local message | ||||||
|
|
||||||
| if [[ -n "$1" ]]; then | ||||||
| message="$1" | ||||||
| else | ||||||
| message="$(cat)" | ||||||
| fi | ||||||
|
|
||||||
| if [[ "$message" == "help" || "$message" == "-h" ]]; then | ||||||
| _about_ok_box | ||||||
| return 0 | ||||||
| fi | ||||||
|
|
||||||
| if [[ -z "$message" ]]; then | ||||||
| echo "Error: Missing message." >&2 | ||||||
| _about_ok_box | ||||||
| return 1 | ||||||
| fi | ||||||
|
|
||||||
| local dialog="${DIALOG:-whiptail}" | ||||||
|
|
||||||
| case "$dialog" in | ||||||
| dialog) | ||||||
| dialog --title "${TITLE:-Info}" --msgbox "$message" 10 80 >/dev/tty 2>&1 | ||||||
| ;; | ||||||
| whiptail) | ||||||
| whiptail --title "${TITLE:-Info}" --msgbox "$message" 10 80 3>&1 1>&2 2>&3 | ||||||
| ;; | ||||||
| read) | ||||||
| echo "$message" | ||||||
| ;; | ||||||
| *) | ||||||
| echo "$message" | ||||||
|
||||||
| echo "$message" | |
| echo "Error: Unsupported dialog tool '$dialog'. Supported tools are: dialog, whiptail, read." >&2 |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| #!/bin/bash | ||
| set -euo pipefail | ||
|
|
||
| # ok_box - Armbian Config V3 test | ||
|
|
||
| if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then | ||
| echo "ok_box - Armbian Config V3 test" | ||
| echo "# TODO: implement module logic" | ||
| exit 1 | ||
| fi | ||
|
|
This file was deleted.
This file was deleted.
This file was deleted.
Uh oh!
There was an error while loading. Please reload this page.