Skip to content

feat(completion): dynamic process-name completion for run/up and process start/stop/restart#524

Open
ilyagr wants to merge 3 commits into
F1bonacc1:mainfrom
ilyagr:task-shell-completion
Open

feat(completion): dynamic process-name completion for run/up and process start/stop/restart#524
ilyagr wants to merge 3 commits into
F1bonacc1:mainfrom
ilyagr:task-shell-completion

Conversation

@ilyagr

@ilyagr ilyagr commented Jul 24, 2026

Copy link
Copy Markdown

Add shell completion to process-name-taking commands such as
process-compose run <TAB>. Uses cobra's ValidArgsFunction
functionality. Should work in every supported shell.

run and up load names from the config file, which also allows them
to pass the first line of the process descriptions (if defined in the
config) to cobra together with the names.

The process start/stop/restart commands query the running server.
The server doesn't currently return the process descriptions (this could
be added relatively easily), so the completions will come without
descriptions.

On any error (missing config or unreachable server) the helpers return
ShellCompDirectiveNoFileComp with no candidates. The config path sets
IsInternalLoader so a malformed or half-edited config returns an error
instead of aborting completion via log.Fatal.


About the third commit, honor --unix-socket ...

That is a preventive fix to a somewhat obscure but really confusing problem
discovered by AI. See the description and the code for details. It comes with
a somewhat heavy-weight AI-generated test to prove that the bug actually exists.

I'm happy to remove that commit if you prefer a different solution, or to
keep the fix and remove the heavy-weight (but IMO easy-to-follow) test.

One potentially better solution IMO would be to remove the -U flag entirely, I'm not
sure it's useful when --unix-socket implies -U but a bare -U creates
a socket at a hard-to-guess path.

@ilyagr
ilyagr force-pushed the task-shell-completion branch 3 times, most recently from 3a2a790 to e52c086 Compare July 24, 2026 05:30
@ilyagr
ilyagr marked this pull request as ready for review July 24, 2026 05:31
ilyagr added 3 commits July 23, 2026 22:44
…ting

envsubst.Eval was the only log.Fatal in the load path not gated by
IsInternalLoader after 33435d8 and aba328e.

A malformed ${...} in the config called os.Exit even for
internal/programmatic loads (reload, tests, and future callers), unlike
the sibling read/parse/unmarshal error handling.
…ess start/stop/restart

Add shell completion to process-name-taking commands such as
`process-compose run <TAB>`. Uses cobra's `ValidArgsFunction`
functionality. Should work in every supported shell.

`run` and `up` load names from the config file, which also allows them
to pass the first line of the process descriptions (if defined in the
config) to `cobra` together with the names.

The `process start/stop/restart` commands query the running server.
The server doesn't currently return the process descriptions (this could
be added relatively easily), so the completions will come without
descriptions. 

On any error (missing config or unreachable server) the helpers return
ShellCompDirectiveNoFileComp with no candidates. The config path sets
IsInternalLoader so a malformed or half-edited config returns an error
instead of aborting completion via log.Fatal.
One of `process-compose` CLI rules is that the `--unix-socket blah` flag
implies `-U`. Because of the way this logic is implemented inside
`PersistentPreRun`, it doesn't work in the completion execution flow
for `completeProcessNamesFromServer`.

Before this commit, tab completion would work correctly for either
`process-compose -U --unix-socket blah process start <TAB>` or
`PC_SOCKET_PATH=blah process-compose ...`, but it would surprisingly not
work for just `process-compose --unix-socket blah ...`.
@ilyagr
ilyagr force-pushed the task-shell-completion branch from e52c086 to 9a10107 Compare July 24, 2026 05:44
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant