fix: consistent usage errors for list, leave, status, who, log
list ignored --help and listed parties; leave and status ignored stray arguments; who silently kept the last of several positionals; log took a positional name that neither its usage nor the man page documents. All now follow the parser convention of the other subcommands: help on -h, exit 2 on an unknown flag or unexpected argument.
This commit is contained in:
parent
9b85485ee8
commit
698fff91ee
2 changed files with 43 additions and 10 deletions
31
party
31
party
|
|
@ -1090,10 +1090,7 @@ Usage: party log [--stop] [--party <name>]
|
|||
EOF
|
||||
exit 0 ;;
|
||||
-*) echo "party log: unknown flag '$1'" >&2; exit 2 ;;
|
||||
*)
|
||||
if [ -z "$partyname" ]; then partyname="$1"; shift
|
||||
else echo "party log: unexpected arg '$1'" >&2; exit 2; fi
|
||||
;;
|
||||
*) echo "party log: unexpected arg '$1'" >&2; exit 2 ;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
|
@ -1277,10 +1274,22 @@ EOF
|
|||
# the socket path.
|
||||
exec "$PARTY_TMUX" -S "$RR_SOCKET" "$@"
|
||||
}
|
||||
cmd_leave() {
|
||||
|
||||
# Argv check for the subcommands that take no arguments. $1 = label.
|
||||
# A stray word is more likely a typo'd subcommand line than something
|
||||
# to ignore, so it is a usage error like everywhere else.
|
||||
_parse_no_args() {
|
||||
label="$1"; shift
|
||||
case "${1:-}" in
|
||||
-h|--help) echo "Usage: party leave"; exit 0 ;;
|
||||
'') ;;
|
||||
-h|--help) echo "Usage: party $label"; exit 0 ;;
|
||||
-*) echo "party $label: unknown flag '$1'" >&2; exit 2 ;;
|
||||
*) echo "party $label: unexpected arg '$1'" >&2; exit 2 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
cmd_leave() {
|
||||
_parse_no_args leave "$@"
|
||||
|
||||
# Walk every live party; for each one we have any presence on
|
||||
# (either via __party_guest_$USER or as a client of the host's
|
||||
|
|
@ -1520,6 +1529,7 @@ cmd_detach() {
|
|||
}
|
||||
|
||||
cmd_list() {
|
||||
_parse_no_args list "$@"
|
||||
found=0 lines='' first_group='' mixed=0
|
||||
for rec in $(roster_list); do
|
||||
roster_read "$rec" || continue
|
||||
|
|
@ -1583,7 +1593,10 @@ cmd_who() {
|
|||
echo "Usage: party who [--short] [--party name|--socket path]"
|
||||
exit 0 ;;
|
||||
-*) echo "party who: unknown flag '$1'" >&2; exit 2 ;;
|
||||
*) partyname="$1"; shift ;;
|
||||
*)
|
||||
if [ -z "$partyname" ]; then partyname="$1"; shift
|
||||
else echo "party who: unexpected arg '$1'" >&2; exit 2; fi
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
|
|
@ -1636,9 +1649,7 @@ cmd_who() {
|
|||
}
|
||||
|
||||
cmd_status() {
|
||||
case "${1:-}" in
|
||||
-h|--help) echo "Usage: party status"; exit 0 ;;
|
||||
esac
|
||||
_parse_no_args status "$@"
|
||||
|
||||
hosting='' joined=''
|
||||
for rec in $(roster_list); do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue