|
1 | | -use clap::Parser; |
| 1 | +use clap::{CommandFactory, Parser, ValueHint}; |
2 | 2 | use git_workspace::commands::{ |
3 | | - add_provider_to_config, archive, execute_cmd, fetch, list, lock, pull_all_repositories, update, |
| 3 | + add_provider_to_config, archive, completion, execute_cmd, fetch, list, lock, |
| 4 | + pull_all_repositories, update, |
4 | 5 | }; |
5 | 6 | use git_workspace::config::ProviderSource; |
6 | 7 | use git_workspace::utils::{ensure_workspace_dir_exists, expand_workspace_path}; |
@@ -67,6 +68,11 @@ enum Command { |
67 | 68 | #[command(subcommand)] |
68 | 69 | command: ProviderSource, |
69 | 70 | }, |
| 71 | + /// Generate shell completions |
| 72 | + Completion { |
| 73 | + /// The shell to generate the completion script for |
| 74 | + shell: clap_complete::Shell, |
| 75 | + }, |
70 | 76 | } |
71 | 77 |
|
72 | 78 | fn main() -> anyhow::Result<()> { |
@@ -98,6 +104,7 @@ fn handle_main(args: Args) -> anyhow::Result<()> { |
98 | 104 | args, |
99 | 105 | } => execute_cmd(&workspace_path, threads, command, args)?, |
100 | 106 | Command::SwitchAndPull { threads } => pull_all_repositories(&workspace_path, threads)?, |
| 107 | + Command::Completion { shell } => completion(shell, &mut Args::command())?, |
101 | 108 | }; |
102 | 109 | Ok(()) |
103 | 110 | } |
0 commit comments