From fa14f40de79bab643e971c49e2fec4313ae1da3d Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Wed, 10 Jan 2024 00:13:48 -0700 Subject: [PATCH] Update armbian-configng script and remove manual_generation.md --- .github/workflows/man-page-deploy.yml | 41 +++++++ bin/armbian-configng | 108 +++++++++++++++++- ...eneration.md => user_manual_generation.md} | 0 3 files changed, 143 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/man-page-deploy.yml rename share/doc/armbian-configng/{manual_generation.md => user_manual_generation.md} (100%) diff --git a/.github/workflows/man-page-deploy.yml b/.github/workflows/man-page-deploy.yml new file mode 100644 index 000000000..8acdf1980 --- /dev/null +++ b/.github/workflows/man-page-deploy.yml @@ -0,0 +1,41 @@ +name: Generate Man Pages + +on: + push: + paths: + - 'share/doc/armbian-configng/*.1.md' + +jobs: + man-page-gen: + name: Generate Man Pages + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Pandoc + run: sudo apt-get install -y pandoc + + - name: Check Pandoc Version + run: pandoc --version + + - name: Convert Markdown to Man Pages + run: | + for file in share/doc/armbian-configng/*.1.md; do + pandoc -s -t man $file -o ${file%.md} + gzip ${file%.md} + done + + - name: Move Man Pages + run: | + mkdir -p share/man/man1 + mv share/doc/armbian-configng/*.1.gz share/man/man1/ + + - name: Commit and Push Changes + run: | + git config --global user.name 'GitHub Actions' + git config --global user.email 'github-actions@github.com' + git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} + git add -A + git commit -m "Generated man pages" || echo "No changes to commit" + git push origin HEAD:${{ github.ref }} \ No newline at end of file diff --git a/bin/armbian-configng b/bin/armbian-configng index e1ec4ceb1..534cd5e3e 100755 --- a/bin/armbian-configng +++ b/bin/armbian-configng @@ -121,7 +121,6 @@ generate_action() { ${function_name} } - generate_help(){ #Usage: ${filename%.*} [flag][option] @@ -142,8 +141,6 @@ Usage: ${0##*/} [OPTION]... example: ${0##*/} --deps git - - options: help Advanced no-interface options help message @@ -151,8 +148,8 @@ Usage: ${0##*/} [OPTION]... This will parse the command to the Group function, and the function will be run. - example: - ${0##*/} [group]=[function] + example: + ${0##*/} [group]=[function] EOF @@ -277,7 +274,7 @@ handle_short_flag(){ exit 0 ; elif [[ "$1" == "--deps" ]] ; then shift - check_dependencies "${@}" + see_get_dependencies "${@}" exit 0 ; elif [[ "$1" == "--server" ]]; then serve_and_open_html @@ -314,3 +311,102 @@ case "$1" in # You can add your code here ;; esac + +############################################################################################### +############################################################################################### + +# This function is used to generate a text-based user interface (TUI) for navigating the menus. +generate_tui() { + local options=() + local i=0 + declare -A categories_array + local help_index=-1 + + for category in "${categories[@]}"; do + local category_name="${category##*/}" + local category_description="" + local category_file="$category/category.conf" + + if [[ -f "$category_file" ]]; then + category_description=$(grep -oP "(?<=# @description ).*" "$category_file") + fi + + if [[ "$category_name" == "help" ]]; then + help_index=$i + else + categories_array["$i"]="$category_name" + description_array["$i"]="$category_description" + options+=("$i" "$(printf '%-7s - %-8s' "${categories_array[$i]}" "${description_array[$i]}")") + ((++i)) + fi + done + + # Add the help category if it exists + if [[ $help_index -ne -1 ]]; then + categories_array["$i"]="help" + description_array["$i"]="Documentation, support, sources" + options+=("$i" "$(printf '%-7s - %-8s' "${categories_array[$i]}" "${description_array[$i]}")") + ((++i)) + fi + + [[ -f /sbin/armbian-config ]] && options+=("$i" "$(printf '%-7s - %-8s' "Legacy" "Run Legacy configuration")") ; ((++i)) ; + [[ ! -d "$libpath/help" ]] && options+=("$i" "$(printf '%-7s - %-8s' "Help" "Documentation, support, sources")") ; ((++i)) ; + + local choice + choice=$($dialogue --menu "Select a category:" 0 0 9 "${options[@]}" 3>&1 1>&2 2>&3) + + if [[ -n $choice ]]; then + if ((choice == "$i - 1")); then + generate_help ; + echo "" ; + generate_list_cli ; + exit 0 ; + elif ((choice == "$i - 2")); then + armbian-config + exit ; + else + generate_sub_tui "${categories_array[$choice]}" + fi + fi +} + +# This function is used to generate a text-based user interface (TUI) for navigating the menus. +generate_sub_tui() { + local category="$1" + local options=() + local i=0 + declare -A functions_array + for file in "$libpath/$category"/*.sh; do + mapfile -t functions_in_file < <(grep -oP '(?<=function\s)\w+::\w+' "$file") + for function in "${functions_in_file[@]}"; do + key="${category##*/}:${file##*/}:${function}" + functions_array["$i"]="$function" + options+=("$i" "${functions["$key,function_name"]} - ${functions["$key,description"]}") + ((++i)) + done + done + + local choice + + choice=$($dialogue --menu "Select a function:" 0 0 9 "${options[@]}" 3>&1 1>&2 2>&3) + + if [[ -n $choice ]]; then + generate_action "${functions_array[$choice]}" | "$directory/bin/armbian-interface" -o + fi + +} + + +if [[ -z "$1" ]] ; then + while true; do + if [[ "$dialogue" == "$file_name" ]]; then + generate_read + elif [[ "$dialogue" != "$file_name" ]]; then + generate_tui + fi + + if [[ "$?" == "0" ]]; then + break + fi + done +fi diff --git a/share/doc/armbian-configng/manual_generation.md b/share/doc/armbian-configng/user_manual_generation.md similarity index 100% rename from share/doc/armbian-configng/manual_generation.md rename to share/doc/armbian-configng/user_manual_generation.md