subx_cli/cli/generate_completion_args.rs
1//! Shell completion script generation command-line arguments.
2//!
3//! This module defines the command-line interface for generating shell completion
4//! scripts that enable tab completion for SubX commands in various shell environments.
5//! This significantly improves the user experience by providing intelligent command
6//! and argument completion.
7//!
8//! # Supported Shells
9//!
10//! SubX can generate completion scripts for all major shells:
11//! - **Bash**: Most common on Linux systems
12//! - **Zsh**: Default on macOS and advanced Linux setups
13//! - **Fish**: Modern shell with powerful completion features
14//! - **PowerShell**: Windows and cross-platform PowerShell environments
15//! - **Elvish**: Modern shell with structured data support
16//!
17//! # Completion Features
18//!
19//! Generated completion scripts provide:
20//! - **Command Completion**: Tab completion for all subcommands
21//! - **Argument Completion**: Intelligent completion for command arguments
22//! - **Path Completion**: File and directory path suggestions
23//! - **Enum Completion**: Valid values for enum-based arguments
24//! - **Help Integration**: Context-aware help text display
25//!
26//! # Installation Examples
27//!
28//! ```bash
29//! # Bash (add to ~/.bashrc)
30//! eval "$(subx generate-completion bash)"
31//!
32//! # Zsh (add to ~/.zshrc)
33//! eval "$(subx generate-completion zsh)"
34//!
35//! # Fish (save to completions directory)
36//! subx generate-completion fish > ~/.config/fish/completions/subx.fish
37//!
38//! # PowerShell (add to profile)
39//! subx generate-completion powershell | Out-String | Invoke-Expression
40//! ```
41
42// src/cli/generate_completion_args.rs
43use clap::Args;
44use clap_complete::Shell;
45
46/// Command-line arguments for generating shell completion scripts.
47///
48/// The generate-completion command creates shell-specific completion scripts
49/// that enable intelligent tab completion for SubX commands and arguments.
50/// This greatly enhances the command-line user experience by providing
51/// context-aware suggestions and reducing typing requirements.
52///
53/// # Completion Capabilities
54///
55/// Generated scripts provide completion for:
56/// - **Subcommands**: `match`, `convert`, `sync`, `detect-encoding`, etc.
57/// - **Flags and Options**: `--format`, `--output`, `--confidence`, etc.
58/// - **Enum Values**: Available formats, AI providers, sync methods
59/// - **File Paths**: Intelligent file and directory completion
60/// - **Configuration Keys**: Valid configuration setting names
61///
62/// # Shell Integration
63///
64/// Each shell has different integration methods:
65/// - **Immediate**: Load completion in current session
66/// - **Persistent**: Add to shell configuration for permanent availability
67/// - **System-wide**: Install for all users on the system
68/// - **Per-project**: Enable completion in specific project directories
69///
70/// # Performance Considerations
71///
72/// Completion scripts are optimized for performance:
73/// - **Lazy Loading**: Completions are generated on-demand
74/// - **Caching**: Results are cached where appropriate
75/// - **Minimal Overhead**: Scripts add minimal startup time to shell
76/// - **Incremental Updates**: Only regenerate when command structure changes
77///
78/// # Examples
79///
80/// ```rust
81/// use subx_cli::cli::GenerateCompletionArgs;
82/// use clap_complete::Shell;
83///
84/// // Generate Bash completion
85/// let bash_args = GenerateCompletionArgs {
86/// shell: Shell::Bash,
87/// };
88///
89/// // Generate Zsh completion
90/// let zsh_args = GenerateCompletionArgs {
91/// shell: Shell::Zsh,
92/// };
93///
94/// // Generate Fish completion
95/// let fish_args = GenerateCompletionArgs {
96/// shell: Shell::Fish,
97/// };
98/// ```
99#[derive(Args, Debug)]
100pub struct GenerateCompletionArgs {
101 /// Target shell for completion script generation
102 #[arg(value_enum)]
103 pub shell: Shell,
104}