Skip to content

Conversation

@drewburlingame
Copy link
Collaborator

@drewburlingame drewburlingame commented Nov 2, 2025

Description

Provide shell completions and a completion command to generate scripts for Bash, Zsh, Fish, and Powershell

Related Issue

Fixes #(issue number)

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring
  • Test improvements
  • CI/CD improvements

Testing

Automated

New Tests Added

  • Unit tests added
  • Feature tests added
  • Integration tests added
  • No tests needed (explain why)

Test Results

all passing

Manual Testing Performed

tested bash and zsh completion scripts

Documentation

  • Updated XML documentation comments
  • Updated README if needed
  • Updated documentation site (docs/) if needed
  • Added/updated code examples in DocExamples
  • No documentation changes needed

Breaking Changes

N/A

Checklist

  • My code follows the project's coding standards
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published

Screenshots (if applicable)

see tests

Additional Context

Reviewer Notes

Implements intelligent shell completion support via [suggest] directive.
Uses full parsing pipeline to provide context-aware suggestions.

Features:
- Context-aware suggestions based on ParseResult
- Enum value completion
- AllowedValues completion
- Partial value filtering
- Parse error handling
- Hidden option exclusion
- Middleware option visibility (--help always suggested)

Implementation:
- SuggestDirectiveMiddleware in CommandDotNet.Completions namespace
- MiddlewareSteps.Suggest runs before Help
- UseSuggestDirective() extension method

Testing:
- 14 comprehensive tests (100% passing)
- All 965 existing tests pass (no regressions)

Documentation:
- docs/OtherFeatures/suggest.md with examples
- Added to features.md
- Registered in mkdocs.yml

This provides the foundation for shell integration.
Next: __complete command to generate shell scripts.
Add CompletionCommand class that apps can include to provide shell completion
script generation for bash, zsh, fish, and PowerShell. Each shell subcommand
outputs a ready-to-use completion script and includes installation instructions
in its help text.

Key changes:
- New CompletionCommand with Bash, Zsh, Fish, and Powershell subcommands
- New ShellCompletionScripts utility for generating shell-specific scripts
- Move UsageAppName from AppSettings.Help to AppSettings.Execution to support
  completion scripts and other execution contexts beyond help text
- Add ExecutionAppSettings to centralize execution-related configuration
- Maintain backwards compatibility for AppSettings.Help.UsageAppName
- Comprehensive test coverage for completion command output and help text
- Update documentation to reflect recommended UsageAppName location

The completion scripts integrate with the [suggest] directive to provide
dynamic command, option, and argument completion based on the current
command context.
@drewburlingame drewburlingame merged commit 7bb02fc into master Nov 3, 2025
8 checks passed
@drewburlingame drewburlingame deleted the shell-completions branch November 3, 2025 00:25
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.

2 participants