Skip to content

Commit

Permalink
makoctl: reject mode positional arguments unless -s is used
Browse files Browse the repository at this point in the history
Instead of silently ignoring extra arguments, print an error to
help users.

References: #468
  • Loading branch information
emersion committed May 10, 2024
1 parent ac0ead9 commit 6373655
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions makoctl
Original file line number Diff line number Diff line change
Expand Up @@ -171,13 +171,16 @@ case "$1" in
exit 1
esac
done
shift $(($OPTIND - 1))
if [ "$add_remove_toggle_flag" = 1 ] && [ "$set_flag" = 1 ]; then
echo >&2 "makoctl: -a/-r and -s cannot be used together"
echo >&2 "makoctl: -a/-r/-t and -s cannot be used together"
exit 1
fi
if [ "$set_flag" = 1 ]; then
shift $(($OPTIND - 1))
modes="$(jq -n '$ARGS.positional' --args "$@")"
elif [ $# -gt 0 ]; then
echo >&2 "makoctl: positional arguments can only be used with -s"
exit 1
fi
if [ "$add_remove_toggle_flag" = 1 ] || [ "$set_flag" = 1 ]; then
modes="$(echo "$modes" | jq '. | unique')"
Expand Down

0 comments on commit 6373655

Please sign in to comment.