@@ -9,7 +9,8 @@ pub mod utils;
99use crate :: utils:: collections:: { uniq, uniq_by} ;
1010use anyhow:: { Result , anyhow} ;
1111use arrow:: ipc:: CompressionType ;
12- use clap:: { Args , Parser , Subcommand , ValueEnum } ;
12+ use clap:: { Args , CommandFactory , Parser , Subcommand , ValueEnum } ;
13+ use clap_complete:: Shell ;
1314use datafusion:: config:: Dialect ;
1415use parquet:: {
1516 basic:: { Compression , Encoding , GzipLevel , ZstdLevel } ,
@@ -29,6 +30,7 @@ pub struct Cli {
2930}
3031
3132#[ derive( Subcommand , Debug ) ]
33+ #[ allow( clippy:: large_enum_variant) ]
3234pub enum Commands {
3335 /// Transform data between formats with optional filtering, sorting, merging, and partitioning.
3436 ///
@@ -46,6 +48,34 @@ pub enum Commands {
4648 /// silk-chiffon transform --from-many '*.arrow' --to-many "{{year}}/{{month}}.parquet" --by year,month
4749 #[ command( verbatim_doc_comment) ]
4850 Transform ( TransformCommand ) ,
51+
52+ /// Generate shell completions for your shell.
53+ ///
54+ /// To add completions for your current shell session only:
55+ /// zsh: eval "$(silk-chiffon completions zsh)"
56+ /// bash: eval "$(silk-chiffon completions bash)"
57+ /// fish: silk-chiffon completions fish | source
58+ ///
59+ /// To persist completions across sessions:
60+ /// zsh: echo 'eval "$(silk-chiffon completions zsh)"' >> ~/.zshrc
61+ /// bash: echo 'eval "$(silk-chiffon completions bash)"' >> ~/.bashrc
62+ /// fish: silk-chiffon completions fish > ~/.config/fish/completions/silk-chiffon.fish
63+ #[ command( verbatim_doc_comment) ]
64+ Completions {
65+ /// Shell to generate completions for
66+ shell : Shell ,
67+ } ,
68+ }
69+
70+ impl Commands {
71+ pub fn generate_completions ( shell : Shell ) {
72+ clap_complete:: generate (
73+ shell,
74+ & mut Cli :: command ( ) ,
75+ "silk-chiffon" ,
76+ & mut std:: io:: stdout ( ) ,
77+ ) ;
78+ }
4979}
5080
5181#[ derive( ValueEnum , Clone , Copy , Debug , Default , Display ) ]
0 commit comments