Skip to content

Commit

Permalink
fix jq null error fixes list and nested menus
Browse files Browse the repository at this point in the history
  • Loading branch information
Tearran committed Sep 6, 2024
1 parent b83338e commit 068c1fa
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 8 deletions.
12 changes: 7 additions & 5 deletions lib/armbian-configng/config.ng.docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
12 changes: 9 additions & 3 deletions lib/armbian-configng/config.ng.functions.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"]=""
Expand Down

0 comments on commit 068c1fa

Please sign in to comment.