From 068c1fa9c3ee8041c842414906ab796ed7f15307 Mon Sep 17 00:00:00 2001 From: Tearran Date: Thu, 5 Sep 2024 21:04:42 -0400 Subject: [PATCH] fix jq null error fixes list and nested menus --- lib/armbian-configng/config.ng.docs.sh | 12 +++++++----- lib/armbian-configng/config.ng.functions.sh | 12 +++++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/lib/armbian-configng/config.ng.docs.sh b/lib/armbian-configng/config.ng.docs.sh index c07b2ed37..292d1a4ec 100644 --- a/lib/armbian-configng/config.ng.docs.sh +++ b/lib/armbian-configng/config.ng.docs.sh @@ -485,13 +485,15 @@ Usage: $script_name [option] [arguments] main=Help - Display Legacy Options (Backward Compatible) EOF - # TODO: Migrate More features. + # TODO: Migrate More features. #echo " main=help - Display Legacy cli commands." jq -r --arg script_name "$script_name" ' - .menu[] | - .sub[] | - select(.id | startswith("H") | not) | - " --cli " + .id + " - " + .description + def process_item(item): + " --cli " + item.id + " - " + item.description, + (item.sub[]? | process_item(.)); + + .menu[] | + .sub[]? | process_item(.) ' $json_file } diff --git a/lib/armbian-configng/config.ng.functions.sh b/lib/armbian-configng/config.ng.functions.sh index 330290bc5..ef1001143 100644 --- a/lib/armbian-configng/config.ng.functions.sh +++ b/lib/armbian-configng/config.ng.functions.sh @@ -566,15 +566,21 @@ module_options+=( # function execute_command() { local id=$1 - local commands=$(jq -r --arg id "$id" '.menu[] | .. | objects | select(.id==$id) | .command[]' "$json_file") + #local commands=$(jq -r --arg id "$id" '.menu[] | .. | objects | select(.id==$id) | .command[]' "$json_file") + local commands=$(jq -r --arg id "$id" ' + .menu[] | + .. | + objects | + select(.id == $id) | + .command[]?' "$json_file") + for command in "${commands[@]}"; do - # Check if the command is not in the list of restricted commands + # Check if the command is not in the list of restricted commands [[ -n "$debug" ]] && echo "$command" eval "$command" done } - module_options+=( ["show_message,author"]="Joey Turner" ["show_message,ref_link"]=""