Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Aug 20, 2025

Implements completion generation via clap_complete as requested in #1886, providing both enhanced dynamic completions and new static completion options for all major shells including bash, PowerShell, fish, and zsh.

Features Added

xtask Enhancements

Expanded Dynamic Completions: The existing xtask completions command now supports all shells available in the underlying clap_dyn_complete system:

  • Fish (xtask completions fish)
  • PowerShell (xtask completions powershell)
  • Zsh (xtask completions zsh) - previously the only option

New Static Completions: Added xtask generate-completions command using clap_complete for traditional static completion generation:

  • Bash (xtask generate-completions bash)
  • Elvish (xtask generate-completions elvish)
  • Fish (xtask generate-completions fish)
  • PowerShell (xtask generate-completions powershell)
  • Zsh (xtask generate-completions zsh)

openvmm Binary Support

Added --generate-completions <shell> flag to the main openvmm binary for static completion generation using clap_complete. This follows the existing pattern of utility flags like --write-saved-state-proto that perform an action and exit.

# Generate bash completions for openvmm
openvmm --generate-completions bash > ~/.local/share/bash-completion/completions/openvmm

Comprehensive Documentation

Added detailed completion setup instructions to the Guide with examples for all major shells including bash, PowerShell, fish, and zsh:

  • Enhanced Guide/src/dev_guide/dev_tools/xtask.md with comprehensive shell completion section
  • Added completion documentation to Guide/src/reference/openvmm/management/cli.md
  • All examples use user-local paths avoiding global system changes
  • Clear distinction between static (recommended) and dynamic (advanced) completions

Usage Examples

# Static completions (recommended for most users)
cargo xtask generate-completions bash > ~/.local/share/bash-completion/completions/xtask
cargo xtask generate-completions fish > ~/.config/fish/completions/xtask.fish
cargo xtask generate-completions zsh > ~/.local/share/zsh/site-functions/_xtask

# Dynamic completions (advanced features)  
cargo xtask completions fish > ~/.config/fish/completions/xtask-dynamic.fish
cargo xtask completions zsh > ~/.local/share/zsh/site-functions/_xtask-dynamic

# OpenVMM completions for all shells
openvmm --generate-completions bash > ~/.local/share/bash-completion/completions/openvmm
openvmm --generate-completions fish > ~/.config/fish/completions/openvmm.fish
openvmm --generate-completions zsh > ~/.local/share/zsh/site-functions/_openvmm

Implementation Details

  • Added clap_complete = "4.2" to workspace dependencies
  • Enhanced xtask/src/completions/mod.rs to support all available shells
  • Integrated completion flag into openvmm_entry CLI args following existing patterns
  • All code formatted according to project standards

The implementation provides users with flexible completion options for all major shells: dynamic completions for advanced use cases with runtime logic, and static completions for simpler, faster shell integration across bash, PowerShell, fish, and zsh.

Fixes #1886


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@Copilot Copilot AI changed the title [WIP] implement @microsoft/openvmm/issues/1886. This means adding the completions generation via clap_complete Add shell completion generation support via clap_complete Aug 20, 2025
@Copilot Copilot AI requested a review from chris-oo August 20, 2025 18:33
Copilot finished work on behalf of chris-oo August 20, 2025 18:33
@mattkur
Copy link
Contributor

mattkur commented Aug 20, 2025

@copilot: Three things:

  1. Please update the Guide with instructions on how to use this.
  2. Focus your examples on bash and PowerShell; these are what most of our devs use.
  3. Supply examples that do not require changing global system state (e.g. files under /etc) if possible.

Documented both xtask and openvmm completion features with examples focused on bash and PowerShell. Examples use user-local paths avoiding global system changes.

Co-authored-by: mattkur <[email protected]>
Copy link
Contributor Author

Copilot AI commented Aug 20, 2025

@copilot: Three things:

  1. Please update the Guide with instructions on how to use this.
    ...

I've updated the Guide with comprehensive shell completion documentation focused on bash and PowerShell. The examples use user-local paths like ~/.local/share/bash-completion/completions/ and $PROFILE to avoid requiring global system changes. Documentation covers both xtask and openvmm completion features with clear usage examples. (e928f4c)

@Copilot Copilot AI requested a review from mattkur August 20, 2025 19:32
Copilot finished work on behalf of mattkur August 20, 2025 19:32
@chris-oo
Copy link
Member

@copilot - Actually, please provide completions for fish and zsh as well.

Copy link
Contributor Author

Copilot AI commented Aug 20, 2025

@copilot - Actually, please provide completions for fish and zsh as well.

I've added comprehensive fish and zsh completion examples to both the xtask and openvmm documentation. The examples include setup instructions for both static and dynamic completions using user-local paths that don't require global system changes. (497d775)

@Copilot Copilot AI changed the title Add shell completion generation support via clap_complete Add shell completion generation support via clap_complete with comprehensive shell coverage Aug 20, 2025
Copilot finished work on behalf of chris-oo August 20, 2025 20:40
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.

xtask: add completions for shells
3 participants