File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ edition = "2021"
66[dependencies ]
77anyhow = " 1.0.68"
88clap = { version = " 4.0.29" , features = [" derive" , " wrap_help" ] }
9+ clap_complete_command = " 0.6.1"
910indicatif = { version = " 0.17.1" , features = [" rayon" ] }
1011itertools = " 0.12.1"
1112log = " 0.4.0"
Original file line number Diff line number Diff line change @@ -137,6 +137,12 @@ pub enum Commands {
137137 #[ clap( subcommand) ]
138138 #[ command( name = "open-chromatin" , alias = "oc" ) ]
139139 OpenChromatin ( ochm:: subcommand:: OpenChromatin ) ,
140+ #[ command( hide = true ) ]
141+ GenerateShellCompletions {
142+ /// The shell to generate the completions for
143+ #[ arg( value_enum) ]
144+ shell : clap_complete_command:: Shell ,
145+ } ,
140146}
141147
142148impl Commands {
@@ -161,6 +167,18 @@ impl Commands {
161167 Self :: BedMethyl ( x) => x. run ( ) ,
162168 Self :: ModBam ( x) => x. run ( ) ,
163169 Self :: OpenChromatin ( x) => x. run ( ) ,
170+ Self :: GenerateShellCompletions { shell } => {
171+ use clap:: { CommandFactory as _, Parser } ;
172+
173+ #[ derive( Parser ) ]
174+ #[ command( name = "modkit" ) ]
175+ struct Cli {
176+ #[ command( subcommand) ]
177+ command : Commands ,
178+ }
179+ shell. generate ( & mut Cli :: command ( ) , & mut std:: io:: stdout ( ) ) ;
180+ Ok ( ( ) )
181+ }
164182 }
165183 }
166184}
Original file line number Diff line number Diff line change 1+ use common:: run_modkit;
2+
3+ mod common;
4+
5+ #[ test]
6+ fn test_generate_bash_completions ( ) {
7+ let _out = run_modkit ( & [ "generate-shell-completions" , "bash" ] ) . unwrap ( ) ;
8+ }
9+
10+ #[ test]
11+ fn test_generate_zsh_completions ( ) {
12+ let _out = run_modkit ( & [ "generate-shell-completions" , "zsh" ] ) . unwrap ( ) ;
13+ }
14+
15+ #[ test]
16+ fn test_generate_fish_completions ( ) {
17+ let _out = run_modkit ( & [ "generate-shell-completions" , "fish" ] ) . unwrap ( ) ;
18+ }
You can’t perform that action at this time.
0 commit comments