fix: close the four known installer bugs (DU-H1, DU-H2, BUG-1, BUG-2)
- DU-H1: flags are parsed wherever they sit, so `install --unattended` and `--unattended install` are the same run; any unknown flag, word, or subcommand exits 2 to stderr before a package manager is touched. - DU-H2: every download lands in one private mktemp -d (mode 700) workdir per run, is checked non-empty before sudo tar sees it, and an EXIT/INT/TERM trap cleans up. No fixed /tmp paths remain. - BUG-1: ^t is now toggle-shown — it ticks only the rows the active filter is showing, and @needs expansion stops at the first invasive row, so an invasive package can never be ticked off-screen. - BUG-2: ^t journals what it added, so a second ^t over the same shown set unticks exactly that set; the bind no longer clears the query. - lab: the type verb polls fzf's reported query to a deadline instead of a fixed sleep; marks_settled retries within its deadline. Suite 256/0 host, 214/0 docker (ubuntu:24.04), mutations 24/24 killed (six new mutants re-introduce each bug and all die), lab 6/6 green.
This commit is contained in:
+194
-36
@@ -24,6 +24,11 @@ EXP=$STATE/expanded
|
||||
# Written when the picker is ACCEPTED, never merely opened. Its presence is the
|
||||
# difference between "chose nothing" and "has not chosen yet".
|
||||
PICKED=$STATE/picked
|
||||
# The journal of the last ^t: the rows it was given, then '=', then the keys it
|
||||
# actually added. One keystroke's worth, not state -- any other keystroke moves
|
||||
# the shown set out from under it, the next ^t sees the mismatch and falls back
|
||||
# to the ordinary toggle rule. See cmd_toggle_shown.
|
||||
TICK=$STATE/ticked
|
||||
|
||||
# The manifest is data, not a script, so it does not live in bin/. Checked in
|
||||
# the development layout first so the repo's own test suite and a checkout both
|
||||
@@ -78,7 +83,17 @@ leaves() {
|
||||
# unticking one unticks what needed it. The counts on screen move as it happens,
|
||||
# so the closure is visible rather than described.
|
||||
|
||||
# stdin: package keys -> stdout: the ones the manifest does NOT flag invasive.
|
||||
drop_invasive() {
|
||||
awk -F'\t' 'NR==FNR { if (!/^[#@]/ && NF>=3 && $3=="invasive") inv[$1"/"$2]=1; next }
|
||||
NF && !($0 in inv)' "$MANIFEST" -
|
||||
}
|
||||
|
||||
# stdin: keys -> stdout: those keys plus everything they need, transitively.
|
||||
#
|
||||
# `expand_deps invasive-stop` stops the walk AT an invasive dependency instead
|
||||
# of walking through it: neither that row nor anything reachable only behind it
|
||||
# is pulled in. ^t is the only caller -- see cmd_toggle_shown.
|
||||
expand_deps() {
|
||||
work=$(sort -u); prev=
|
||||
while [ "$work" != "$prev" ]; do
|
||||
@@ -93,6 +108,7 @@ expand_deps() {
|
||||
*) awk -F'\t' -v g="$d" '!/^[#@]/ && NF>=3 && $1==g {print $1"/"$2}' "$MANIFEST" ;;
|
||||
esac
|
||||
done)
|
||||
[ "${1:-}" != invasive-stop ] || add=$(printf '%s\n' "$add" | drop_invasive)
|
||||
work=$(printf '%s\n%s\n' "$work" "$add" | grep . | sort -u)
|
||||
done
|
||||
printf '%s\n' "$work"
|
||||
@@ -138,6 +154,54 @@ cmd_toggle() {
|
||||
sort -u "$tmp" > "$tmp.s" && mv "$tmp.s" "$SEL" && rm -f "$tmp"
|
||||
}
|
||||
|
||||
# ------------------------------------------------------ toggle every shown ---
|
||||
# ^t, and only ^t. Deliberately NOT cmd_toggle over the visible rows; the two
|
||||
# differences are both safety properties rather than taste.
|
||||
#
|
||||
# 1. A bulk keystroke must not tick a row you cannot see. cmd_toggle widens
|
||||
# along @needs, and over a filter those edges reach off screen: `nvidia`
|
||||
# shows three gpu rows, gpu/container-toolkit @needs docker, and one ^t used
|
||||
# to switch on three invasive daemon packages that were never drawn. So the
|
||||
# forward walk here STOPS at an invasive dependency. A row that is ON SCREEN
|
||||
# may still be invasive and is still ticked -- you are looking at it, and
|
||||
# that is the whole difference. An invasive need left unticked is not lost:
|
||||
# `explain` and the plan already report an unmet @needs.
|
||||
# 2. ^t is its own undo. The keys it actually moved are journalled in $TICK, so
|
||||
# a second press over the same rows takes back exactly those and nothing
|
||||
# else. The reverse @needs closure cannot do that job -- nothing needs the
|
||||
# gpu rows, so it would never let go of what the forward press pulled in.
|
||||
# Any other keystroke changes the shown set, the journal stops matching, and
|
||||
# ^t falls back to cmd_toggle's plain all-on/all-off rule.
|
||||
cmd_toggle_shown() {
|
||||
shown=$(leaves "$@" | sort -u)
|
||||
[ -n "$shown" ] || return 0
|
||||
all_on=1
|
||||
for k in $shown; do grep -qxF "$k" "$SEL" || { all_on=0; break; }; done
|
||||
tmp=$STATE/.sel.$$
|
||||
if [ "$all_on" -eq 1 ]; then
|
||||
if [ -f "$TICK" ] && [ "$shown" = "$(sed '/^=$/,$d' "$TICK")" ]; then
|
||||
go=$(sed '1,/^=$/d' "$TICK")
|
||||
else
|
||||
go=$(printf '%s\n' "$shown" | expand_rdeps)
|
||||
fi
|
||||
rm -f "$TICK"
|
||||
# An empty journal means the forward press added nothing, so there is
|
||||
# nothing to hand back. It must never reach the grep below: an empty
|
||||
# pattern list matches every line, and -v would erase the selection.
|
||||
[ -n "$go" ] || return 0
|
||||
grep -vxF -f - "$SEL" > "$tmp" <<-EOF || :
|
||||
$go
|
||||
EOF
|
||||
sort -u "$tmp" > "$tmp.s"
|
||||
else
|
||||
go=$(printf '%s\n' "$shown" | expand_deps invasive-stop)
|
||||
add=$(printf '%s\n' "$go" | grep -vxF -f "$SEL" || :)
|
||||
{ cat "$SEL"; printf '%s\n' "$go"; } | grep . | sort -u > "$tmp.s" || :
|
||||
{ printf '%s\n=\n' "$shown"; [ -z "$add" ] || printf '%s\n' "$add"; } > "$TICK"
|
||||
fi
|
||||
mv "$tmp.s" "$SEL"; rm -f "$tmp"
|
||||
}
|
||||
|
||||
cmd_expand() {
|
||||
for key in "$@"; do
|
||||
case $key in g:*) g=${key#g:} ;; p:*) g=${key#p:}; g=${g%%/*} ;; *) continue ;; esac
|
||||
@@ -360,6 +424,36 @@ if [ "$(id -u)" != 0 ] && command -v sudo >/dev/null 2>&1; then SUDO=sudo; fi
|
||||
FAILED=$STATE/.failed.$$
|
||||
APT_UPDATED=0
|
||||
|
||||
# One private directory per run, for everything this script downloads.
|
||||
#
|
||||
# The three tarball handlers wrote /tmp/nvim.tgz, /tmp/node.tgz and /tmp/go.tgz
|
||||
# -- fixed names in a world-writable directory -- and then unpacked them with
|
||||
# `sudo tar`. Anyone with an account on the box could pre-create those names as
|
||||
# symlinks, or swap the file in the window between the download and the extract,
|
||||
# and have tar write their content anywhere as root. The deb channel's
|
||||
# ${TMPDIR:-/tmp}/dotup-$$.deb was only slightly better: a pid is a small number
|
||||
# and it is reused.
|
||||
#
|
||||
# mktemp -d is 700 by definition; the chmod says so out loud rather than trusting
|
||||
# every mktemp on every platform to agree. Created on first use, so a run that
|
||||
# downloads nothing leaves nothing behind, and removed on the way out either way.
|
||||
# Sets $WORKDIR rather than printing it, and the callers read the variable. A
|
||||
# `wd=$(workdir)` would run the whole thing in a SUBSHELL: every caller would
|
||||
# get a directory of its own, the parent's $WORKDIR would stay empty, and the
|
||||
# trap below would have nothing to remove. Written that way first, and the
|
||||
# suite's "does not outlive the run" assertion is what said so.
|
||||
WORKDIR=
|
||||
workdir() {
|
||||
[ -z "$WORKDIR" ] || return 0
|
||||
WORKDIR=$(mktemp -d "${TMPDIR:-/tmp}/dotup.XXXXXX") || {
|
||||
err "could not create a private working directory"; return 1; }
|
||||
chmod 700 "$WORKDIR" || { err "could not lock down $WORKDIR"; return 1; }
|
||||
}
|
||||
# Named, not inlined into the trap, because cmd_private installs a trap of its
|
||||
# own further down and has to be able to call this one as well.
|
||||
dotup_cleanup() { [ -z "${WORKDIR:-}" ] || rm -rf "$WORKDIR"; WORKDIR=; }
|
||||
trap dotup_cleanup EXIT INT TERM
|
||||
|
||||
have() { find_tool "$1" >/dev/null 2>&1; }
|
||||
|
||||
# A tool installed a moment ago is not on this process's PATH: the astral
|
||||
@@ -665,6 +759,7 @@ install_deb() {
|
||||
srcs=$(norm "$1")
|
||||
[ -n "$srcs" ] || return 0
|
||||
head_ "deb"
|
||||
deb_n=0
|
||||
for s in $srcs; do
|
||||
url=$s
|
||||
case $s in
|
||||
@@ -688,7 +783,9 @@ install_deb() {
|
||||
[ -n "$url" ] || { note_fail "$(keyof deb "$s")" "no release asset matching *$match*"; continue; }
|
||||
fi ;;
|
||||
esac
|
||||
f=${TMPDIR:-/tmp}/dotup-$$.deb
|
||||
workdir || { note_fail "$(keyof deb "$s")" "no private working directory"; continue; }
|
||||
deb_n=$((deb_n + 1))
|
||||
f=$WORKDIR/pkg-$deb_n.deb
|
||||
apt_update_once
|
||||
run_sh "curl -fsSL '$url' -o '$f'" || { note_fail "$(keyof deb "$s")" "download failed"; continue; }
|
||||
run_sh "${SUDO:+$SUDO }apt-get install -y '$f'" || note_fail "$(keyof deb "$s")" "dpkg install failed"
|
||||
@@ -718,13 +815,18 @@ install_bespoke() {
|
||||
aarch64|arm64) a=arm64 ;;
|
||||
*) note_fail "$key" "no neovim tarball for $(uname -m)"; continue ;;
|
||||
esac
|
||||
workdir || { note_fail "$key" "no private working directory"; continue; }
|
||||
b=https://github.com/neovim/neovim/releases/latest/download
|
||||
run_sh "curl -fsSL '$b/nvim-linux-$a.tar.gz' -o /tmp/nvim.tgz || curl -fsSL '$b/nvim-linux64.tar.gz' -o /tmp/nvim.tgz" \
|
||||
|| { note_fail "$key" "tarball download failed"; continue; }
|
||||
run_sh "${SUDO:+$SUDO }rm -rf /opt/nvim && ${SUDO:+$SUDO }mkdir -p /opt/nvim && ${SUDO:+$SUDO }tar -xzf /tmp/nvim.tgz -C /opt/nvim --strip-components=1" \
|
||||
# The `[ -s ]` is part of the download, not a step after it: nothing
|
||||
# may reach `sudo tar` that was not verified to be here and non-empty
|
||||
# first. A zero-byte file is what a proxy error page truncated to
|
||||
# nothing looks like, and tar's complaint about it is not a sentence
|
||||
# anyone can act on.
|
||||
run_sh "{ curl -fsSL '$b/nvim-linux-$a.tar.gz' -o '$WORKDIR/nvim.tgz' || curl -fsSL '$b/nvim-linux64.tar.gz' -o '$WORKDIR/nvim.tgz'; } && [ -s '$WORKDIR/nvim.tgz' ]" \
|
||||
|| { note_fail "$key" "tarball download failed or arrived empty"; continue; }
|
||||
run_sh "${SUDO:+$SUDO }rm -rf /opt/nvim && ${SUDO:+$SUDO }mkdir -p /opt/nvim && ${SUDO:+$SUDO }tar -xzf '$WORKDIR/nvim.tgz' -C /opt/nvim --strip-components=1" \
|
||||
|| { note_fail "$key" "tarball extract failed"; continue; }
|
||||
run_sh "${SUDO:+$SUDO }ln -sf /opt/nvim/bin/nvim /usr/local/bin/nvim"
|
||||
run_sh "rm -f /tmp/nvim.tgz" ;;
|
||||
run_sh "${SUDO:+$SUDO }ln -sf /opt/nvim/bin/nvim /usr/local/bin/nvim" ;;
|
||||
core/node)
|
||||
# Same call as core/neovim, for the same reason and with better
|
||||
# evidence. 24.04's apt candidate is node 18.19.1; three of the four
|
||||
@@ -748,14 +850,14 @@ install_bespoke() {
|
||||
| awk -F'\t' 'NR==1{for(i=1;i<=NF;i++) if($i=="lts") c=i; next}
|
||||
c && $c!="-" {print $1; exit}'); fi
|
||||
[ -n "$v" ] || { note_fail "$key" "could not resolve the current node LTS"; continue; }
|
||||
run_sh "curl -fsSL 'https://nodejs.org/dist/$v/node-$v-$o-$a.tar.gz' -o /tmp/node.tgz" \
|
||||
|| { note_fail "$key" "tarball download failed"; continue; }
|
||||
run_sh "${SUDO:+$SUDO }rm -rf /opt/node && ${SUDO:+$SUDO }mkdir -p /opt/node && ${SUDO:+$SUDO }tar -xzf /tmp/node.tgz -C /opt/node --strip-components=1" \
|
||||
workdir || { note_fail "$key" "no private working directory"; continue; }
|
||||
run_sh "curl -fsSL 'https://nodejs.org/dist/$v/node-$v-$o-$a.tar.gz' -o '$WORKDIR/node.tgz' && [ -s '$WORKDIR/node.tgz' ]" \
|
||||
|| { note_fail "$key" "tarball download failed or arrived empty"; continue; }
|
||||
run_sh "${SUDO:+$SUDO }rm -rf /opt/node && ${SUDO:+$SUDO }mkdir -p /opt/node && ${SUDO:+$SUDO }tar -xzf '$WORKDIR/node.tgz' -C /opt/node --strip-components=1" \
|
||||
|| { note_fail "$key" "tarball extract failed"; continue; }
|
||||
run_sh "${SUDO:+$SUDO }ln -sf /opt/node/bin/node /usr/local/bin/node"
|
||||
run_sh "${SUDO:+$SUDO }ln -sf /opt/node/bin/npm /usr/local/bin/npm"
|
||||
run_sh "${SUDO:+$SUDO }ln -sf /opt/node/bin/npx /usr/local/bin/npx"
|
||||
run_sh "rm -f /tmp/node.tgz" ;;
|
||||
run_sh "${SUDO:+$SUDO }ln -sf /opt/node/bin/npx /usr/local/bin/npx" ;;
|
||||
core/go)
|
||||
if have go && [ "$DRYRUN" -eq 0 ]; then say " go already present — leaving it"; continue; fi
|
||||
case $(uname -s) in Darwin) o=darwin ;; *) o=linux ;; esac
|
||||
@@ -764,11 +866,11 @@ install_bespoke() {
|
||||
if [ "$DRYRUN" -eq 1 ]; then v='go1.X.Y'
|
||||
else v=$(curl -fsSL 'https://go.dev/VERSION?m=text' 2>/dev/null | head -1); fi
|
||||
[ -n "$v" ] || { note_fail "$key" "could not resolve the current go version"; continue; }
|
||||
run_sh "curl -fsSL 'https://go.dev/dl/$v.$o-$a.tar.gz' -o /tmp/go.tgz" \
|
||||
|| { note_fail "$key" "tarball download failed"; continue; }
|
||||
run_sh "${SUDO:+$SUDO }rm -rf /usr/local/go && ${SUDO:+$SUDO }tar -xzf /tmp/go.tgz -C /usr/local" \
|
||||
|| { note_fail "$key" "tarball extract failed"; continue; }
|
||||
run_sh "rm -f /tmp/go.tgz" ;;
|
||||
workdir || { note_fail "$key" "no private working directory"; continue; }
|
||||
run_sh "curl -fsSL 'https://go.dev/dl/$v.$o-$a.tar.gz' -o '$WORKDIR/go.tgz' && [ -s '$WORKDIR/go.tgz' ]" \
|
||||
|| { note_fail "$key" "tarball download failed or arrived empty"; continue; }
|
||||
run_sh "${SUDO:+$SUDO }rm -rf /usr/local/go && ${SUDO:+$SUDO }tar -xzf '$WORKDIR/go.tgz' -C /usr/local" \
|
||||
|| { note_fail "$key" "tarball extract failed"; continue; } ;;
|
||||
core/chezmoi)
|
||||
# Circular by nature: dotup arrives *via* chezmoi. Present already
|
||||
# in every case that matters; here for the one where it is not.
|
||||
@@ -961,8 +1063,11 @@ cmd_private() {
|
||||
say " The address is in no repository. Leave it blank to stay public-only."
|
||||
# Read into variables: nothing reaches argv, so nothing reaches `ps`.
|
||||
P_URL=''; P_USER=''; P_PW=''; p_in=''
|
||||
# This REPLACES the load-time trap rather than adding to it, so it has to do
|
||||
# that trap's job too: without the dotup_cleanup call the run's private
|
||||
# working directory outlived the run whenever the private tier was reached.
|
||||
# shellcheck disable=SC2064
|
||||
trap 'unset P_URL P_USER P_PW P_BLOB p_repo p_tok p_cred 2>/dev/null || :' EXIT INT TERM
|
||||
trap 'unset P_URL P_USER P_PW P_BLOB p_repo p_tok p_cred 2>/dev/null || :; dotup_cleanup' EXIT INT TERM
|
||||
|
||||
# Ask, and keep asking.
|
||||
#
|
||||
@@ -1264,12 +1369,22 @@ cmd_pick() {
|
||||
nl='
|
||||
'
|
||||
hdr="space tick tab open ^t tick all shown ^a defaults ^x none ^o open all enter install$nl"
|
||||
# clear-query in the ^t bind below is not cosmetic. ^t toggles every row
|
||||
# the filter shows, and the toggle widens along @needs -- so typing
|
||||
# `nvidia` and pressing ^t also ticked docker-ce, docker-buildx and
|
||||
# docker-compose, all of them `invasive`, none of them on screen. The rule
|
||||
# this repo states is "never silently", not "never": dropping the query
|
||||
# puts what just happened in front of you.
|
||||
# ^t is `toggle-shown`, not `toggle`, and the difference is the two bugs
|
||||
# this bind used to have. Full reasoning above cmd_toggle_shown; the
|
||||
# semantics, stated once:
|
||||
#
|
||||
# ^t ticks every row the filter is showing, plus what those rows @needs
|
||||
# as far as the first invasive dependency -- an invasive row is ticked
|
||||
# only by ticking the visible row itself. Pressing ^t again over the same
|
||||
# rows unticks exactly the keys the first press added, so ^t ^t is a
|
||||
# no-op. Over rows that were already all on, ^t is the ordinary all-off
|
||||
# with the reverse @needs closure.
|
||||
#
|
||||
# `clear-query` used to hang off the end of this bind, because the toggle
|
||||
# reached rows the query was hiding and the rule here is "never silently".
|
||||
# Nothing is hidden any more, and the query has to survive the keystroke
|
||||
# for the second press to be the undo of the first -- clearing it made ^t
|
||||
# ^t mean "tick the three rows I filtered for, then tick the manifest".
|
||||
cmd_render | "$FZF" --ansi --exact --no-sort --cycle --multi --layout=reverse --height=100% \
|
||||
--delimiter='\t' --with-nth=1 --pointer='>' --marker=' ' \
|
||||
--info=inline --border=none \
|
||||
@@ -1277,7 +1392,7 @@ cmd_pick() {
|
||||
--preview "$SELF explain {2}" --preview-window='right,46%,wrap,border-left' \
|
||||
--bind "space:execute-silent($SELF toggle {2})+reload($SELF render)" \
|
||||
--bind "tab:execute-silent($SELF expand {2})+reload($SELF render)" \
|
||||
--bind "ctrl-t:select-all+execute-silent($SELF toggle {+2})+clear-selection+clear-query+reload($SELF render)" \
|
||||
--bind "ctrl-t:select-all+execute-silent($SELF toggle-shown {+2})+clear-selection+reload($SELF render)" \
|
||||
--bind "ctrl-a:execute-silent($SELF preset defaults)+reload($SELF render)" \
|
||||
--bind "ctrl-x:execute-silent($SELF preset none)+reload($SELF render)" \
|
||||
--bind "ctrl-o:execute-silent($SELF expand-all)+reload($SELF render)" \
|
||||
@@ -1316,7 +1431,11 @@ cmd_run() {
|
||||
# ------------------------------------------------------------------ usage ----
|
||||
usage() {
|
||||
cat >&2 <<-EOF
|
||||
usage: dotup [--unattended] [--print] [--yes]
|
||||
usage: dotup [--unattended] [--print] [--yes] [command [args]]
|
||||
|
||||
Flags may come before the command, after it, or both --
|
||||
\`dotup install --unattended\` and \`dotup --unattended install\` are the
|
||||
same run. Anything not listed here is an error, never a shrug.
|
||||
|
||||
(no flags) the picker, then install what you ticked
|
||||
--unattended no UI: safe defaults, never prompts, never private
|
||||
@@ -1330,23 +1449,61 @@ usage() {
|
||||
way back in after a mistyped password -- no reinstall.
|
||||
|
||||
plumbing, called by the fzf bindings:
|
||||
render toggle expand expand-all preset explain plan preflight
|
||||
render toggle toggle-shown expand expand-all preset explain plan preflight
|
||||
EOF
|
||||
}
|
||||
|
||||
# Flags are read wherever they sit: before the subcommand, after it, or both.
|
||||
#
|
||||
# The old loop stopped at the first bare word and left the rest of the command
|
||||
# line sitting in "$@", where nothing ever looked at it again. So `dotup install
|
||||
# --unattended` -- the order half the people who type this type it in -- ran a
|
||||
# full ATTENDED install: the flag was accepted by the parser's silence and then
|
||||
# dropped on the floor. That is how a machine meant to get the safe defaults got
|
||||
# every invasive row in the manifest instead.
|
||||
#
|
||||
# Two rules, and the second matters as much as the first: every argument is
|
||||
# parsed wherever it appears, and anything unrecognised -- a flag or a word --
|
||||
# stops the run HERE, before a package manager has been asked for anything. A
|
||||
# flag we do not understand is not a flag we are entitled to ignore.
|
||||
CMD=
|
||||
while [ $# -gt 0 ]; do
|
||||
case $1 in
|
||||
--unattended) UNATTENDED=1; ASSUME_YES=1 ;;
|
||||
--print|-n) DRYRUN=1 ;;
|
||||
--yes|-y) ASSUME_YES=1 ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
--*) err "unknown flag: $1"; usage; exit 2 ;;
|
||||
*) CMD=$1; shift; break ;;
|
||||
esac
|
||||
shift
|
||||
endopts=0
|
||||
n=$#; i=0
|
||||
while [ "$i" -lt "$n" ]; do
|
||||
i=$((i + 1)); a=$1; shift
|
||||
if [ "$endopts" -eq 0 ]; then
|
||||
case $a in
|
||||
--) endopts=1; continue ;;
|
||||
--unattended) UNATTENDED=1; ASSUME_YES=1; continue ;;
|
||||
--print|-n) DRYRUN=1; continue ;;
|
||||
--yes|-y) ASSUME_YES=1; continue ;;
|
||||
-h|--help) usage; exit 0 ;;
|
||||
-?*) err "unknown flag: $a"; usage; exit 2 ;;
|
||||
esac
|
||||
fi
|
||||
# The first bare word is the subcommand; every later one is an operand,
|
||||
# rotated to the back of "$@" so the dispatch below reads them in the order
|
||||
# they were typed with the flags taken out from between them.
|
||||
if [ -z "$CMD" ]; then CMD=$a; else set -- "$@" "$a"; fi
|
||||
done
|
||||
|
||||
# What each subcommand accepts. -1 is "as many as you like". An unknown
|
||||
# subcommand, or one word more than a subcommand can use, is the same class of
|
||||
# mistake as an unknown flag and gets the same answer: say so, and stop.
|
||||
# This list and the dispatch below must name the same commands.
|
||||
amin=0; amax=0
|
||||
case ${CMD:-run} in
|
||||
run|pick|install|private|render|expand-all|plan|preflight|fzf-path) ;;
|
||||
toggle|toggle-shown|expand) amax=-1 ;;
|
||||
preset|explain|resolve) amax=1 ;;
|
||||
vercmp) amin=2; amax=2 ;;
|
||||
*) err "unknown command: $CMD"; usage; exit 2 ;;
|
||||
esac
|
||||
[ "$#" -ge "$amin" ] || { err "${CMD:-run} needs $amin argument(s), got $#"; usage; exit 2; }
|
||||
[ "$amax" -lt 0 ] || [ "$#" -le "$amax" ] || {
|
||||
err "${CMD:-run} takes at most $amax argument(s), got $#:$(printf ' %s' "$@")"
|
||||
usage; exit 2; }
|
||||
|
||||
case ${CMD:-run} in
|
||||
run) cmd_run ;;
|
||||
pick) cmd_pick && cmd_plan ;;
|
||||
@@ -1354,6 +1511,7 @@ install) cmd_install ;;
|
||||
private) cmd_private ;;
|
||||
render) cmd_render ;;
|
||||
toggle) cmd_toggle "$@" ;;
|
||||
toggle-shown) cmd_toggle_shown "$@" ;;
|
||||
expand) cmd_expand "$@" ;;
|
||||
expand-all) cmd_expand_all ;;
|
||||
preset) cmd_preset "${1:-defaults}" ;;
|
||||
|
||||
Reference in New Issue
Block a user