diff options
Diffstat (limited to 'pkgs/claude-inbox.nix')
| -rw-r--r-- | pkgs/claude-inbox.nix | 115 |
1 files changed, 72 insertions, 43 deletions
diff --git a/pkgs/claude-inbox.nix b/pkgs/claude-inbox.nix index 2f1dc79..dca2865 100644 --- a/pkgs/claude-inbox.nix +++ b/pkgs/claude-inbox.nix @@ -15,49 +15,76 @@ let usage() { cat <<'EOF' - usage: claude-inbox [REPO] [BRANCH] [COMMAND] [OPTION...], in any order - COMMAND: --list (the default without BRANCH), --show (the default with - BRANCH), --take, --push. REPO: a repository in DIR, with a remote - claude; BRANCH: one of claude's there, or without REPO, in the one - repository that has it (by the last fetch; --show fetches first). A - word that could be either is what makes sense of all the words, if - exactly one reading does. Where a command needs REPO and gets none - (--show without BRANCH, --push), it's the one the current directory - is in, if any. - --list [REPO] [--by-remote] fetches the repositories the VM has (ssh - HOST: its ~/src, but for symlinks), or just REPO, from their remote - claude, here in DIR, and shows the branches there with something - master doesn't have, by content, and those it has all of (to delete), - and whether master needs pushing. OWNER: the remote, by the branch's - prefix, or tv, without one. STATE: review (it's new, and master's in - it), rebase (master moved on: the remote's turn), done (master has it - all: to delete), yours (tv's own); * marks what changed since --show - or --take. --by-remote: grouped by OWNER. - --show REPO|BRANCH [--diff[=WHAT]]: master..BRANCH, with patches (and - BRANCH is seen); --diff: the diff to BRANCH from WHAT (any branch or - commit), by default from HEAD; without BRANCH, REPO's branches, as a - graph. Fetches first: REPO, or without it, all of DIR's. - --take BRANCH [-f|--force|--pick]: fast-forward master to BRANCH, as - last fetched (i.e. as shown), and push it to claude; --force: rename - master to abandoned/master-DATE, make BRANCH master (with the old - one's upstream), and push it like --push --force; --pick: put the - commits of BRANCH that master doesn't have yet (by content) on top of - it, one by one (a rebase, but onto master, and on it: on a conflict, - it stops there, to resolve and git cherry-pick --continue, then - --push, or --abort), and push it. master: checked out, or not at all - (not in another worktree); --pick needs it checked out. - --push REPO [-f|--force]: master to claude; --force for a rewritten - master, but only while claude's is still the one last fetched - (--force-with-lease). Both push master to claude's master, and give - master that upstream, if it has none. - OPTION, besides a command's: -d DIR ($CLAUDE_INBOX_SRC, or ~/sync/src), - --vm HOST ($CLAUDE_INBOX_VM, or claude), --no-fetch. + usage: claude-inbox [REPO] [BRANCH] [COMMAND] [OPTION...] + (in any order) + + What among the claude VM's repositories needs attention, and doing it. + + Commands: + --list [REPO] [--by-remote] + The default without BRANCH. Fetch the repositories the VM has + (ssh HOST: its ~/src, but for symlinks), or just REPO, and show + their branches with something master doesn't have (by content), + those it has all of (to delete), and whether master needs + pushing. --by-remote: grouped by OWNER. + --show [REPO|BRANCH] [--diff[=WHAT]] + The default with BRANCH. Fetch REPO (or else all) first, show + master..BRANCH, with patches, and mark BRANCH seen. Without + BRANCH: REPO's branches, as a graph. + --diff: the diff to BRANCH from WHAT, a branch or commit + (default: HEAD). + --take BRANCH [-f|--force|--pick] + Fast-forward master to BRANCH, as last fetched (i.e. as shown), + and push it to claude. master: checked out, or nowhere (not in + another worktree). + --force: rename master to abandoned/master-DATE, make BRANCH + master (with the old one's upstream), push it like --push -f. + --pick: put the commits of BRANCH that master doesn't have yet + (by content) on top of it, one by one, and push it; on a + conflict, it stops there: resolve, git cherry-pick --continue, + then --push; or git cherry-pick --abort. Needs master checked + out. + --push [REPO] [-f|--force] + Push master to claude's master (and make that master's + upstream, if it has none). + --force: for a rewritten master, but only while claude's is the + one last fetched (git push --force-with-lease). + + Words: + REPO a repository in DIR, with a remote claude; where a command + needs one and gets none, the one the current directory is + in + BRANCH a branch of claude's there; without REPO, in the one + repository that has it (as last fetched) + A word that could be either is what makes sense of all the words, + if exactly one reading does. + + Options: + -d DIR the repositories ($CLAUDE_INBOX_SRC, or ~/sync/src) + --vm HOST the VM ($CLAUDE_INBOX_VM, or claude) + --no-fetch don't fetch (--list, --show) + -h, --help this + + The list: + OWNER the remote, by the branch's prefix (?: no such remote), or + tv, without one + STATE review new, and master is in it + rebase master moved on: the remote's turn + done master has it all: to delete + yours tv's own + * changed since --show or --take + NEW its commits that master doesn't have, by content + BEHIND master's commits that it doesn't have + AGE of its last commit + master push: master is ahead of claude's; VM-ahead!: claude's has + what master doesn't EOF } # colors, if FD (1 or 2) is a terminal, as completion has them: - # commands, options, REPO, BRANCH; none with NO_COLOR, or a dumb one + # commands, options, REPO, BRANCH, and bold for headings; none with + # NO_COLOR, or a dumb one colors() { - C_CMD= C_OPT= C_REPO= C_BRANCH= C_OFF= + C_CMD= C_OPT= C_REPO= C_BRANCH= C_HEAD= C_OFF= test -t "$1" && test -z "''${NO_COLOR-}" || return 0 case ''${TERM-dumb} in dumb | "") return 0 ;; esac local n p @@ -75,14 +102,16 @@ let esac set -- $p C_CMD=$'\e['$1m C_OPT=$'\e['$2m C_REPO=$'\e['$3m C_BRANCH=$'\e['$4m C_OFF=$'\e[0m' + C_HEAD=$'\e[1m' } - # the commands, options, REPO and BRANCH in a text (the help, an - # error), in their colors, if any (a colored word follows an m, so - # each loop ends) + # the headings (bold), commands, options, REPO and BRANCH in a text + # (the help, an error), in their colors, if any (a colored word + # follows an m, so each loop ends) paint() { if test -z "$C_OFF"; then cat; return; fi local x='[^-A-Za-z0-9_]' sed -E \ + -e "s/^([A-Z][A-Za-z ]*:)$/$C_HEAD\1$C_OFF/" \ -e ":a; s/(^|$x)(--(list|show|take|push)|COMMAND)($x|$)/\1$C_CMD\2$C_OFF\4/; ta" \ -e ":b; s/(^|$x)(-d|--vm|--no-fetch|--by-remote|-f|--force|--pick|--diff|-h|--help|OPTION)($x|$)/\1$C_OPT\2$C_OFF\3/; tb" \ -e ":c; s/(^|$x)(REPO)($x|$)/\1$C_REPO\2$C_OFF\3/; tc" \ @@ -133,7 +162,7 @@ let --diff) diff=1 what= ;; --diff=*) diff=1 what=''${1#--diff=} ;; -h | --help) colors 1; usage | paint; exit ;; - -*) colors 2; usage | paint >&2; exit 1 ;; + -*) die "$1: no such option (claude-inbox -h)" ;; *) words+=("$1") esac shift |
