Skip to content

Commit

Permalink
Update armbian-configng script and remove manual_generation.md
Browse files Browse the repository at this point in the history
  • Loading branch information
GitHub Actions committed Jan 10, 2024
1 parent 1ce0f70 commit fa14f40
Show file tree
Hide file tree
Showing 3 changed files with 143 additions and 6 deletions.
41 changes: 41 additions & 0 deletions .github/workflows/man-page-deploy.yml
Original file line number Diff line number Diff line change
@@ -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 '[email protected]'
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 }}
108 changes: 102 additions & 6 deletions bin/armbian-configng
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ generate_action() {
${function_name}
}


generate_help(){

#Usage: ${filename%.*} [flag][option]
Expand All @@ -142,17 +141,15 @@ Usage: ${0##*/} [OPTION]...
example:
${0##*/} --deps git
options:
help Advanced no-interface options help message
$( generate_list_cli )
This will parse the command to the Group function, and the function will be run.
example:
${0##*/} [group]=[function]
example:
${0##*/} [group]=[function]
EOF

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

0 comments on commit fa14f40

Please sign in to comment.