Tormak9970 / bash-shortcuts

A Steam Deck plugin for creating custom shortcuts that can be launched from the Quick Access Menu. Uses Bash under the hood.
Other
32 stars 8 forks source link

Proper documentation for using flags passed by hooks #27

Closed HirschBerge closed 8 months ago

HirschBerge commented 1 year ago

SteamOS ver: 3.5 Decky Loader Ver: 2.10.4 I'm sure this will make a lot of sense when I know how to use it, but currently, if you don't know how to properly pass a flag provided by a hook to your script, it's "f you, buddy." You'd think it would just have the command, for example, ~/test.sh and it would add the flags to the end of the command to make it in actuality ~/test.sh -i 123123 -h "Game Start" -n "Trails from Zero"

Example contents of ~\test.sh being

#!/usr/bin/env bash

while getopts "h:i:n:" opt; do
  case "$opt" in
    h) action="$OPTARG" ;;
    i) steamID="$OPTARG" ;;
    n) game="$OPTARG" ;;
    ?) echo "script usage: $(basename $0) [-h Action] [-i Steam ID] [-n Game Name]" >&2
       exit 1 ;;
  esac
done
shift "$((OPTIND - 1))"
current_time=$(date +"%Y-%m-%d %H:%M:%S")
echo -en "$current_time\nAction: $action\nSteamID: $steamID\nGame Title: $game\n"> /tmp/test.log

So please add some more use-case-oriented documentation for making use of the hooks.

Edit: Clarity and aggressiveness.

Tormak9970 commented 1 year ago

SteamOS ver: 3.5 Decky Loader Ver: 2.10.4 I'm sure this will make a lot of sense when I know how to use it, but currently, if you don't know how to properly pass a flag provided by a hook to your script, it's "f you, buddy." You'd think it would just have the command, for example, ~/test.sh and it would add the flags to the end of the command to make it in actuality ~/test.sh -i 123123 -h "Game Start" -n "Trails from Zero"

Example contents of ~\test.sh being

#!/usr/bin/env bash

while getopts "h:i:n:" opt; do
  case "$opt" in
    h) action="$OPTARG" ;;
    i) steamID="$OPTARG" ;;
    n) game="$OPTARG" ;;
    ?) echo "script usage: $(basename $0) [-h Action] [-i Steam ID] [-n Game Name]" >&2
       exit 1 ;;
  esac
done
shift "$((OPTIND - 1))"
current_time=$(date +"%Y-%m-%d %H:%M:%S")
echo -en "$current_time\nAction: $action\nSteamID: $steamID\nGame Title: $game\n"> /tmp/test.log

So please add some more use-case-oriented documentation for making use of the hooks.

Edit: Clarity and aggressiveness.

Hmm, you shouldn't need to add the flags manually, so this is a bug

HirschBerge commented 1 year ago

Hmm, you shouldn't need to add the flags manually, so this is a bug

Thanks for the response! just to clarify what I meant, the ~/test.sh -i 123123 -h "Game Start" -n "Trails from Zero" example I provided is what I would expect to be the command actually passed by the hook, I am not manually putting that info in. The actual command I have for the hook is simply ~/test.sh. I just concatenated the flags and values onto the end to visualize what I would expect to happen.

HirschBerge commented 8 months ago

Closing, as owner has no intention of creating usable documentation

kidoman commented 7 months ago

@HirschBerge did you ever figure out how the flags are being passed when a script it called? I am also not seeing any flags being passed in, when i echo $*

Is that functionality simply broken?