FRAMEWORK: added "--open" to open a component found in features.json + help fix

This commit is contained in:
XargonWan 2025-02-07 09:48:05 +09:00
parent d86918d3de
commit 296caa939d
2 changed files with 48 additions and 1 deletions

View file

@ -1010,3 +1010,45 @@ portmaster_show(){
log e "\"$1\" is not a valid choice, quitting"
fi
}
open_component(){
if [[ -z "$1" ]]; then
cmd=$(jq -r '.emulator[] | select(.ponzu != true) | .name' "$features" | sort)
if [[ "$akai_ponzu" == "true" ]]; then
cmd+="\n$(jq -r '.emulator[] | select(.name == "citra" and .ponzu == true) | .name' "$features")"
fi
if [[ "$kiroi_ponzu" == "true" ]]; then
cmd+="\n$(jq -r '.emulator[] | select(.name == "yuzu" and .ponzu == true) | .name' "$features")"
fi
echo -e "This command expects one of the following components as arguments:\n$(echo -e "$cmd" | sort)"
return
fi
if [[ "$1" == "--getlist" ]]; then
cmd=$(jq -r '.emulator[] | select(.ponzu != true) | .name' "$features" | sort)
if [[ "$akai_ponzu" == "true" ]]; then
cmd+="\n$(jq -r '.emulator[] | select(.name == "citra" and .ponzu == true) | .name' "$features")"
fi
if [[ "$kiroi_ponzu" == "true" ]]; then
cmd+="\n$(jq -r '.emulator[] | select(.name == "yuzu" and .ponzu == true) | .name' "$features")"
fi
echo -e "$cmd" | sort
return
fi
cmd=$(jq -r --arg name "$1" '.emulator[] | select(.name == $name and .ponzu != true) | .launch' "$features")
if [[ -z "$cmd" && "$akai_ponzu" == "true" && "$1" == "citra" ]]; then
cmd=$(jq -r '.emulator[] | select(.name == "citra" and .ponzu == true) | .launch' "$features")
fi
if [[ -z "$cmd" && "$kiroi_ponzu" == "true" && "$1" == "yuzu" ]]; then
cmd=$(jq -r '.emulator[] | select(.name == "yuzu" and .ponzu == true) | .launch' "$features")
fi
if [[ -n "$cmd" ]]; then
eval "$cmd" "${@:2}"
else
echo "Invalid component name: $1"
echo "Please be sure that the casing is correct and if a space is present, the name is quoted."
fi
}

View file

@ -29,7 +29,8 @@ Arguments:
--reset-component <component> \t Reset one or more component or emulator configs to the default values
--reset-retrodeck \t Starts the initial RetroDECK installer (backup your data first!)
--test-upgrade <version> \t Test upgrading RetroDECK to a specific version, developer use only
--set <preset> [value] \t Set or toggle a preset. Examples: --set borders, --set borders true, --set borders gba false. --set help for more help
--set <preset> <system/all> [value] \t Set or toggle a preset. Examples: --set borders, --set borders all true, --set borders gba false. --set help for more help
--open <component/emulator> \t Open a specific component or emulator, --open --getlist for a list of available components
Game Launch:
[<options>] <game_path> \t Start a game using the default emulator or\n\t\t\t\t\t\t the one defined in ES-DE for game or system
@ -165,6 +166,10 @@ for i in "$@"; do
make_preset_changes "$preset" "$value"
exit 0
;;
--open*)
open_component "${@:2}"
exit 0
;;
*)
# Assume unknown arguments are game start arguments
if [ -f "$i" ]; then