feat(completion): auto-detect shell and install when no arg given#64
Merged
Conversation
matter completion with no argument now reads $SHELL, maps it to a supported shell (bash/zsh/fish), and installs completions automatically. On Windows it defaults to powershell. When detection fails (unset $SHELL or unsupported shell like nushell) the error names the valid values explicitly instead of printing cobra's generic usage error. Closes #58
There was a problem hiding this comment.
Pull request overview
This PR updates the matter completion command to make no-argument usage behave like an “install completions” workflow by default, using shell auto-detection to remove the current arg-count error and improve first-run ergonomics (closes #58).
Changes:
- Make the shell argument optional (
MaximumNArgs(1)), and when omitted auto-detect the shell and run installation. - Add
detectShell()to map$SHELLto a supported shell (and default topowershellon Windows) with clearer error messages when detection fails. - Expand test coverage for no-arg behavior and shell detection.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
cli/completion.go |
Makes completion argument optional, adds shell auto-detection, and installs automatically on no-arg invocation with improved help text. |
cli/completion_test.go |
Adds tests for no-arg auto-detect/install behavior and unit tests for detectShell(). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Ensures Dependabot (and human) PRs can't be merged until gofmt, golangci-lint, `go test -race` on Ubuntu + macOS, and the build task all succeed. Also extends Dependabot to track GitHub Actions versions weekly.
Bumps [jdx/mise-action](https://github.com/jdx/mise-action) from 2 to 4. - [Release notes](https://github.com/jdx/mise-action/releases) - [Changelog](https://github.com/jdx/mise-action/blob/main/CHANGELOG.md) - [Commits](jdx/mise-action@v2...v4) --- updated-dependencies: - dependency-name: jdx/mise-action dependency-version: '4' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…#55) Bumps [github.com/charmbracelet/x/term](https://github.com/charmbracelet/x) from 0.2.1 to 0.2.2. - [Commits](charmbracelet/x@ansi/v0.2.1...ansi/v0.2.2) --- updated-dependencies: - dependency-name: github.com/charmbracelet/x/term dependency-version: 0.2.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [golang.org/x/crypto](https://github.com/golang/crypto) from 0.48.0 to 0.50.0. - [Commits](golang/crypto@v0.48.0...v0.50.0) --- updated-dependencies: - dependency-name: golang.org/x/crypto dependency-version: 0.50.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [tinygo.org/x/bluetooth](https://github.com/tinygo-org/bluetooth) from 0.14.0 to 0.15.0. - [Release notes](https://github.com/tinygo-org/bluetooth/releases) - [Changelog](https://github.com/tinygo-org/bluetooth/blob/dev/CHANGELOG.md) - [Commits](tinygo-org/bluetooth@v0.14.0...v0.15.0) --- updated-dependencies: - dependency-name: tinygo.org/x/bluetooth dependency-version: 0.15.0 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [github.com/mattn/go-isatty](https://github.com/mattn/go-isatty) from 0.0.20 to 0.0.21. - [Commits](mattn/go-isatty@v0.0.20...v0.0.21) --- updated-dependencies: - dependency-name: github.com/mattn/go-isatty dependency-version: 0.0.21 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…e shell list - Document in Long/Example that Windows no-arg invocation always uses PowerShell - Introduce supportedShells var as single source of truth for ValidArgs and detectShell error messages
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.
Summary
Closes #58.
matter completion(no args) now reads$SHELL, maps it to a supported shell (bash/zsh/fish), and installs completions automatically — no flags neededpowershell$SHELLor unsupported shell likenushell), the error explicitly names the valid values instead of printing cobra's generic arg-count errormatter completion <shell>(explicit, no--install) still prints to stdout — unchangedmatter completion <shell> --installstill installs explicitly — unchangedTest plan
TestCompletionNoArgs_AutoDetect— bash/zsh/fish each auto-detect and installTestCompletionNoArgs_UnsetShell— empty$SHELLreturns helpful errorTestCompletionNoArgs_UnsupportedShell— e.g./bin/nushellreturns error naming valid valuesTestDetectShell— unit tests for all detection cases (valid paths, empty, unsupported)