@@ -17,47 +17,8 @@ pub enum TimeStyle {
1717 Normal ,
1818}
1919
20- // TODO: flatten options in struct?
2120#[ derive( Debug , Parser ) ]
22- #[ command( author, about, long_about = None , version) ]
23- pub struct Args {
24- #[ command( subcommand) ]
25- cmd : Option < Cmd > ,
26-
27- #[ arg( verbatim_doc_comment) ]
28- /// Provide ID required by other options
29- /// Example: cnb --id 114514 post --show
30- #[ arg( long) ]
31- pub id : Option < usize > ,
32-
33- #[ arg( verbatim_doc_comment) ]
34- /// Reverse list output
35- /// Example: cnb --rev ing list
36- #[ arg( long) ]
37- pub rev : bool ,
38-
39- #[ arg( verbatim_doc_comment) ]
40- /// Skip items while request list
41- /// Example: cnb --skip 2 ing list
42- /// Use this option to save network I/O if some items of the list output are not needed
43- /// If this option is required but not specified, it will be set to 0
44- #[ arg( long) ]
45- #[ arg( short = 's' ) ]
46- #[ arg( value_name = "LENGTH" ) ]
47- pub skip : Option < usize > ,
48-
49- #[ arg( verbatim_doc_comment) ]
50- /// Take items while request list
51- /// Example: cnb --take 2 ing list
52- /// Use this option to save network I/O if only a subset of the list output are required
53- /// <LENGTH> should be in the range [0,100]
54- /// If <LENGTH> is greater than 100, it will be set to 100
55- /// If this option is required but not specified, it will be set to 8
56- #[ arg( long) ]
57- #[ arg( short = 't' ) ]
58- #[ arg( value_name = "LENGTH" ) ]
59- pub take : Option < usize > ,
60-
21+ pub struct GlobalOpt {
6122 #[ arg( verbatim_doc_comment) ]
6223 /// Execute with specific PAT
6324 /// Example: cnb --with-pat 'FOOBARBAZ' post --list
@@ -118,3 +79,47 @@ pub struct Args {
11879 #[ arg( default_value_t = false ) ]
11980 pub quiet : bool ,
12081}
82+
83+ // TODO: flatten options in struct?
84+ #[ derive( Debug , Parser ) ]
85+ #[ command( author, about, long_about = None , version) ]
86+ pub struct Args {
87+ #[ command( subcommand) ]
88+ pub cmd : Option < Cmd > ,
89+ #[ clap( flatten) ]
90+ pub global_opt : GlobalOpt ,
91+
92+ #[ arg( verbatim_doc_comment) ]
93+ /// Provide ID required by other options
94+ /// Example: cnb --id 114514 post --show
95+ #[ arg( long) ]
96+ pub id : Option < usize > ,
97+
98+ #[ arg( verbatim_doc_comment) ]
99+ /// Reverse list output
100+ /// Example: cnb --rev ing list
101+ #[ arg( long) ]
102+ pub rev : bool ,
103+
104+ #[ arg( verbatim_doc_comment) ]
105+ /// Skip items while request list
106+ /// Example: cnb --skip 2 ing list
107+ /// Use this option to save network I/O if some items of the list output are not needed
108+ /// If this option is required but not specified, it will be set to 0
109+ #[ arg( long) ]
110+ #[ arg( short = 's' ) ]
111+ #[ arg( value_name = "LENGTH" ) ]
112+ pub skip : Option < usize > ,
113+
114+ #[ arg( verbatim_doc_comment) ]
115+ /// Take items while request list
116+ /// Example: cnb --take 2 ing list
117+ /// Use this option to save network I/O if only a subset of the list output are required
118+ /// <LENGTH> should be in the range [0,100]
119+ /// If <LENGTH> is greater than 100, it will be set to 100
120+ /// If this option is required but not specified, it will be set to 8
121+ #[ arg( long) ]
122+ #[ arg( short = 't' ) ]
123+ #[ arg( value_name = "LENGTH" ) ]
124+ pub take : Option < usize > ,
125+ }
0 commit comments