Complete command arguments from the manifest; widen the platform filter - #243
Merged
Merged
Conversation
--platform trellis matched entry.Platform exactly, so it returned the 29 Trellis commands and hid the 32 tagged @platform any — the image converters, git helpers and release scripts that run perfectly well on a Trellis box. The flag reads as "what can I run here?", and that answer was wrong by 32 commands. Same for --platform wordpress, and for the listing scope under `trellis ops`, which takes the same path. The widening stops at "any". Rolling wordpress into a trellis filter would return the whole catalog, at which point the flag says nothing. --platform any stays exact, since "what needs no WordPress at all" is a real question and this is the only way left to ask it. catalog.RunsOnPlatform now holds that relation in one place, shared by FilterByPlatform and list.go's per-category filterEntriesByPlatform so the category view and the summary counts can't disagree. search keeps its [platform] badge under --platform now too: a filtered result set mixes trellis rows with any ones, so the badge still distinguishes them.
Shell completion stopped at the command name. `wp-ops db-pull <TAB>`
offered nothing, even though the script header two directories away
declares `site` and `env` with {production|staging} — the CLI had the
answer parsed and indexed and never put it on screen.
It now completes the argument slots too, on all three invocation forms
(bare basename, category + name, full key), resolving the command the
same way execution does. What each slot offers depends on what the
manifest knows:
- declared {a|b} choices become the completion values;
- `site` / `site-name` complete from the group_vars of the Trellis
project in front of you, since that answer lives in the project rather
than in the script — silently detected, never prompting, because a
completion function must not ask questions;
- a slot that holds a path hands back to the shell's own file
completion;
- anything else gets one line of ActiveHelp naming the argument, whether
it is required, and what it means.
A bracketed manifest value is deliberately never offered as a value.
{example.com}, {~/wp-cli.phar} and {/opt/plesk/php/8.2/bin/php} are
placeholders showing the shape of an answer; inserting one as though it
were a default would be worse than offering nothing, so they appear as
"e.g." inside the hint instead.
Typing a dash offers the command's own @Flag lines plus --help and
--where, which executeEntry handles for every command.
Flags are skipped rather than parsed when counting which slot is being
filled: wp-ops re-parses no script's flag grammar, so it cannot know
whether the token after --host is that flag's value or the next
positional. The approximation is right for the common cases and costs a
keystroke, not a mistake, in the rest.
Two assertions in dispatch_test.go said completion must stop once a
basename is present. That was the old grammar's contract; they now pin
the unresolvable-name case instead, with a note recording the reversal.
Tier 1 of Phase G is closed. Replaces both items' "not started" notes with what was actually built and why: the slot-by-slot completion table, the three decisions worth carrying forward (placeholders are never offered as values, site names come from the project silently until M5's registry exists, flags are skipped rather than parsed), and the reason G6's floated --platform-only turned out not to be needed. Also corrects a figure in the G6 write-up: the honest answer for a Trellis user is 61 of 80, not the 41 the item guessed at.
Both are user-facing surfaces the README already describes one level short of: it covered `wp-ops init` installing completion without saying what now completes, and described --platform without saying that trellis and wordpress admit the commands that need no WordPress.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes tier 1 of
docs/cli-ux-plan.mdPhase G: G3 (argument completion) and G6 (--platformsemantics). Released as 5.26.0.G3 — argument completion from the manifest
Shell completion stopped at the command name.
wp-ops db-pull <TAB>offered nothing, even though the script header declaressiteandenvwith{production|staging}— the CLI had that parsed and indexed and never put it on screen.It now completes the argument slots too, on all three invocation forms (bare basename, category + name, full key), resolving the command the same way execution does. An ambiguous basename completes nothing: the entries behind it may declare different arguments, and it wouldn't run either.
What a slot offers depends on what the manifest knows about it:
@argwith{a|b}choicessite/site-namegroup_vars/*/wordpress_sites.ymlinput,*-file,*-dir, …)-@flagnames, plus--helpand--whereThree decisions worth flagging for review:
{example.com},{~/wp-cli.phar},{/opt/plesk/php/8.2/bin/php}are placeholders showing the shape of an answer, not defaults. Inserting one would be worse than offering nothing, so they appear as "e.g." inside the hint.resolveTrellisDir()confirms a detected directory interactively, which a completion function must never do, socompletionSites()takes$TRELLIS_DIRor a silently detected project.internal/detect/sites.goreads it with a line scanner rather than pulling a YAML dependency into the binary for four lines of well-known structure — a stopgap until M5's shared site registry exists.DisableFlagParsingeverywhere), so it cannot know whether the token after--hostis that flag's value or the next positional. Counting only non-flag tokens is right for the common cases and, in the--flag value positionalcase, offers the previous slot — wrong in a way that costs a keystroke, not a mistake, since nothing is inserted without the user picking it.Two assertions in
dispatch_test.gopinned the old two-token grammar ("no completions once a basename is already chosen"). They now pin the unresolvable-name case, with a comment recording that the reversal is deliberate.G6 —
--platform trellisincludes the commands that need no WordPressFilterByPlatformmatched@platformexactly, so--platform trellisreturned the 29 Trellis commands and hid the 32 taggedany— the image converters, git helpers and release scripts that run perfectly well on a Trellis box. The flag reads as "what can I run here?", and that answer was wrong by 32 commands. It now returns 61;--platform wordpressreturns 51.The widening stops there. Rolling
wordpressinto atrellisfilter would return the whole catalog, at which point the flag says nothing.--platform anystays exact, since "what needs no WordPress at all" is a real question and that is the only way left to ask it — which is why the separate--platform-onlythe plan floated wasn't needed.catalog.RunsOnPlatformholds the relation in one place, shared withlist.go's per-categoryfilterEntriesByPlatformso the category view and the summary counts can't disagree.searchkeeps its[platform]badge under--platformnow: a filtered result set mixes[trellis]rows with[any]ones, so the badge still distinguishes them. The listing scope undertrellis opswidens with it, viadefaultPlatform().Verification
go vetandgo test ./...green. Beyond the unit tests, completion was driven through a real interactive zsh over a pty against the installed_wp-opsscript:wp-ops db-pull <TAB>→ the project's site names, with the argument's descriptionwp-ops db-pull example.com <TAB>→production stagingwp-ops jpg-to-webp <TAB>→ the hint above an ordinary file menuThe installed completion script already supports ActiveHelp, so no reinstall is needed to see the hints.