Commit 01b68e0a authored by Mikhail Tergoev's avatar Mikhail Tergoev

Merge branch 'user-conf-cli' of github.com:Boria138/PortWINE into Boria138-user-conf-cli

parents 9c956fbe 147cffa5
...@@ -3213,6 +3213,58 @@ edit_user_conf_from_gui () { ...@@ -3213,6 +3213,58 @@ edit_user_conf_from_gui () {
return 0 return 0
} }
# Manage USER.conf values (get, set, delete)
manage_user_conf_value () {
local action="$1"
local var_name="$2"
local var_value="$3"
if [[ -z "${action}" ]] || [[ -z "${var_name}" ]]; then
print_error "Action and variable name must be provided"
return 1
fi
if [[ ! -f "${USER_CONF}" ]]; then
print_error "USER.conf file does not exist: ${USER_CONF}"
return 1
fi
case "$action" in
get)
if grep -q "^export ${var_name}=" "${USER_CONF}" ; then
# Extract the value, handling both quoted and unquoted values
local value=$(grep "^export ${var_name}=" "${USER_CONF}" | sed -E 's/^export [^=]+=("?)(.*)\1$/\2/')
echo "$value"
return 0
else
# Variable not found in USER.conf
return 1
fi
;;
set)
if [[ -z "${var_value}" ]]; then
print_error "Variable value must be provided for set action"
return 1
fi
export "$var_name=$var_value"
edit_user_conf_from_gui "$var_name"
return 0
;;
delete)
if grep -q "^export ${var_name}=" "${USER_CONF}" ; then
sed -i "/^export ${var_name}=/d" "${USER_CONF}"
print_info "Removed ${var_name} from USER.conf"
fi
return 0
;;
*)
print_error "Invalid action: $action. Use get, set, or delete"
return 1
;;
esac
}
use_exiftool () { use_exiftool () {
if [[ ! -f "${PW_TMPFS_PATH}/exiftool.tmp" ]] \ if [[ ! -f "${PW_TMPFS_PATH}/exiftool.tmp" ]] \
|| ! grep -q "$1" "${PW_TMPFS_PATH}/exiftool.tmp" || ! grep -q "$1" "${PW_TMPFS_PATH}/exiftool.tmp"
......
...@@ -428,9 +428,34 @@ case "$1" in ...@@ -428,9 +428,34 @@ case "$1" in
--launch ${translations[Launches the application immediately, requires the path to the .exe file]} --launch ${translations[Launches the application immediately, requires the path to the .exe file]}
--edit-db ${translations[After the variable, the path to the .exe file is required and then the variables. --edit-db ${translations[After the variable, the path to the .exe file is required and then the variables.
(List their variables and values for example PW_MANGOHUD=1 PW_VKBASALT=0, etc.)]} (List their variables and values for example PW_MANGOHUD=1 PW_VKBASALT=0, etc.)]}
--get-user-conf ${translations[Get a value from user.conf file, requires variable name]}
--set-user-conf ${translations[Set a value in user.conf file, requires variable name and value]}
--del-user-conf ${translations[Delete a value from user.conf file, requires variable name]}
--list-db ${translations[List all available database variables]}
--show-ppdb ${translations[Show the content of .ppdb file for specified .exe file]}
--backup-prefix ${translations[Backup specified prefix to a file]}
--restore-prefix ${translations[Restore prefix from backup file]}
--winefile ${translations[Open wine file explorer, requires WINE version and prefix name]}
--winecfg ${translations[Open wine configuration, requires WINE version and prefix name]}
--winecmd ${translations[Open wine command prompt, requires WINE version and prefix name]}
--winereg ${translations[Open wine registry editor, requires WINE version and prefix name]}
--wine_uninstaller ${translations[Open wine uninstaller, requires WINE version and prefix name]}
--clear_pfx ${translations[Clear specified prefix, requires WINE version and prefix name]}
--initial ${translations[Initial setup command]}
--autoinstall ${translations[--autoinstall and the name of what needs to be installed is given in the list below:]} --autoinstall ${translations[--autoinstall and the name of what needs to be installed is given in the list below:]}
$(echo $files_from_autoinstall | awk '{for (i = 1; i <= NF; i++) {if (i % 10 == 0) {print ""} printf "%s ", $i}}') $(echo $files_from_autoinstall | awk '{for (i = 1; i <= NF; i++) {if (i % 10 == 0) {print ""} printf "%s ", $i}}')
${translations[Usage examples:]}
portproton cli --launch /path/to/game.exe
portproton cli --edit-db /path/to/game.exe PW_MANGOHUD=1 PW_VKBASALT=0
portproton cli --get-user-conf PW_MANGOHUD
portproton cli --set-user-conf PW_MANGOHUD 1
portproton cli --del-user-conf PW_MANGOHUD
portproton cli --backup-prefix DEFAULT /path/to/backup/directory
portproton cli --restore-prefix /path/to/backup/file.ppack
portproton cli --winecfg WINE_LG DEFAULT
portproton cli --autoinstall [script_name_from_pw_autoinstall]
" "
} }
help_info help_info
...@@ -468,6 +493,21 @@ $(echo $files_from_autoinstall | awk '{for (i = 1; i <= NF; i++) {if (i % 10 == ...@@ -468,6 +493,21 @@ $(echo $files_from_autoinstall | awk '{for (i = 1; i <= NF; i++) {if (i % 10 ==
edit_db_from_gui $keys_all edit_db_from_gui $keys_all
exit 0 exit 0
;; ;;
--get-user-conf)
# --get-user-conf VARIABLE_NAME
manage_user_conf_value get "$2"
exit 0
;;
--set-user-conf)
# --set-user-conf VARIABLE_NAME VALUE
manage_user_conf_value set "$2" "$3"
exit 0
;;
--delete-user-conf)
# --delete-user-conf VARIABLE_NAME
manage_user_conf_value delete "$2"
exit 0
;;
--list-db) --list-db)
export pw_yad="" export pw_yad=""
gui_edit_db gui_edit_db
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment