dotcli: fix help falling through to git.
This commit is contained in:
@@ -3,14 +3,24 @@
|
||||
## Architecture
|
||||
|
||||
`dot` is defined in one file: `~/.config/fish/functions/dot.fish`. It holds
|
||||
two functions:
|
||||
three functions:
|
||||
|
||||
- `dot` (`--wraps=git`) — dispatches `init` and any file found under
|
||||
- `dot` (`--wraps=git`) — dispatches `init`, `help`, and any file found under
|
||||
`~/.config/dot/commands/`, otherwise forwards everything to
|
||||
`git --git-dir=~/.dotfiles --work-tree=$HOME $argv` (full passthrough).
|
||||
- `__dot_init` — the bootstrap logic, inlined in the same file rather than
|
||||
autoloaded separately, because it's the one subcommand that must work
|
||||
before the dotfiles repo has ever been cloned onto a machine.
|
||||
- `__dot_help` — prints usage: the built-in commands plus whatever is
|
||||
currently found under `~/.config/dot/commands/`, generated by globbing that
|
||||
directory rather than a hardcoded list, so it can't drift from reality.
|
||||
|
||||
`__dot_help`'s glob over `~/.config/dot/commands/*.fish` is duplicated in
|
||||
`~/.config/fish/completions/dot.fish`'s `__dot_custom_subcommands` rather than
|
||||
shared: fish only autoloads a function from a file named after that function,
|
||||
so a helper defined inside `dot.fish` would be undefined if tab-completion
|
||||
ran before `dot` had ever been sourced in the session. Keep both copies in
|
||||
sync when the listing logic changes.
|
||||
|
||||
`dot init`:
|
||||
|
||||
@@ -33,9 +43,9 @@ of `dot` itself.
|
||||
1. Create `~/.config/dot/commands/<name>.fish` defining a `_dot_<name>`
|
||||
function.
|
||||
2. Confirm `dot <name>` dispatches to it. No other wiring is needed —
|
||||
`~/.config/fish/completions/dot.fish` discovers new command files by
|
||||
globbing that directory, and `--wraps=git` still covers raw git
|
||||
subcommands.
|
||||
`~/.config/fish/completions/dot.fish` and `__dot_help` both discover new
|
||||
command files by globbing that directory, and `--wraps=git` still covers
|
||||
raw git subcommands.
|
||||
3. Add a case to `~/.config/dot/tests/dot.fish` covering it and run
|
||||
`fishtape ~/.config/dot/tests/dot.fish` until it passes.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user