@@ -26,6 +26,13 @@ pub use clap::Command;
2626
2727use super :: config:: JobsConfig ;
2828
29+ pub mod heading {
30+ pub const PACKAGE_SELECTION : & str = "Package Selection" ;
31+ pub const TARGET_SELECTION : & str = "Target Selection" ;
32+ pub const FEATURE_SELECTION : & str = "Feature Selection" ;
33+ pub const COMPILATION_OPTIONS : & str = "Compilation Options" ;
34+ }
35+
2936pub trait CommandExt : Sized {
3037 fn _arg ( self , arg : Arg ) -> Self ;
3138
@@ -37,8 +44,10 @@ pub trait CommandExt: Sized {
3744 all : & ' static str ,
3845 exclude : & ' static str ,
3946 ) -> Self {
40- self . arg_package_spec_no_all ( package, all, exclude)
41- . _arg ( flag ( "all" , "Alias for --workspace (deprecated)" ) )
47+ self . arg_package_spec_no_all ( package, all, exclude) . _arg (
48+ flag ( "all" , "Alias for --workspace (deprecated)" )
49+ . help_heading ( heading:: PACKAGE_SELECTION ) ,
50+ )
4251 }
4352
4453 /// Variant of arg_package_spec that does not include the `--all` flag
@@ -51,19 +60,24 @@ pub trait CommandExt: Sized {
5160 exclude : & ' static str ,
5261 ) -> Self {
5362 self . arg_package_spec_simple ( package)
54- . _arg ( flag ( "workspace" , all) )
55- . _arg ( multi_opt ( "exclude" , "SPEC" , exclude) )
63+ . _arg ( flag ( "workspace" , all) . help_heading ( heading :: PACKAGE_SELECTION ) )
64+ . _arg ( multi_opt ( "exclude" , "SPEC" , exclude) . help_heading ( heading :: PACKAGE_SELECTION ) )
5665 }
5766
5867 fn arg_package_spec_simple ( self , package : & ' static str ) -> Self {
59- self . _arg ( optional_multi_opt ( "package" , "SPEC" , package) . short ( 'p' ) )
68+ self . _arg (
69+ optional_multi_opt ( "package" , "SPEC" , package)
70+ . short ( 'p' )
71+ . help_heading ( heading:: PACKAGE_SELECTION ) ,
72+ )
6073 }
6174
6275 fn arg_package ( self , package : & ' static str ) -> Self {
6376 self . _arg (
6477 optional_opt ( "package" , package)
6578 . short ( 'p' )
66- . value_name ( "SPEC" ) ,
79+ . value_name ( "SPEC" )
80+ . help_heading ( heading:: PACKAGE_SELECTION ) ,
6781 )
6882 }
6983
@@ -94,11 +108,13 @@ pub trait CommandExt: Sized {
94108 all : & ' static str ,
95109 ) -> Self {
96110 self . arg_targets_lib_bin_example ( lib, bin, bins, example, examples)
97- . _arg ( flag ( "tests" , tests) )
98- . _arg ( optional_multi_opt ( "test" , "NAME" , test) )
99- . _arg ( flag ( "benches" , benches) )
100- . _arg ( optional_multi_opt ( "bench" , "NAME" , bench) )
101- . _arg ( flag ( "all-targets" , all) )
111+ . _arg ( flag ( "tests" , tests) . help_heading ( heading:: TARGET_SELECTION ) )
112+ . _arg ( optional_multi_opt ( "test" , "NAME" , test) . help_heading ( heading:: TARGET_SELECTION ) )
113+ . _arg ( flag ( "benches" , benches) . help_heading ( heading:: TARGET_SELECTION ) )
114+ . _arg (
115+ optional_multi_opt ( "bench" , "NAME" , bench) . help_heading ( heading:: TARGET_SELECTION ) ,
116+ )
117+ . _arg ( flag ( "all-targets" , all) . help_heading ( heading:: TARGET_SELECTION ) )
102118 }
103119
104120 fn arg_targets_lib_bin_example (
@@ -109,11 +125,14 @@ pub trait CommandExt: Sized {
109125 example : & ' static str ,
110126 examples : & ' static str ,
111127 ) -> Self {
112- self . _arg ( flag ( "lib" , lib) )
113- . _arg ( flag ( "bins" , bins) )
114- . _arg ( optional_multi_opt ( "bin" , "NAME" , bin) )
115- . _arg ( flag ( "examples" , examples) )
116- . _arg ( optional_multi_opt ( "example" , "NAME" , example) )
128+ self . _arg ( flag ( "lib" , lib) . help_heading ( heading:: TARGET_SELECTION ) )
129+ . _arg ( flag ( "bins" , bins) . help_heading ( heading:: TARGET_SELECTION ) )
130+ . _arg ( optional_multi_opt ( "bin" , "NAME" , bin) . help_heading ( heading:: TARGET_SELECTION ) )
131+ . _arg ( flag ( "examples" , examples) . help_heading ( heading:: TARGET_SELECTION ) )
132+ . _arg (
133+ optional_multi_opt ( "example" , "NAME" , example)
134+ . help_heading ( heading:: TARGET_SELECTION ) ,
135+ )
117136 }
118137
119138 fn arg_targets_bins_examples (
@@ -123,15 +142,21 @@ pub trait CommandExt: Sized {
123142 example : & ' static str ,
124143 examples : & ' static str ,
125144 ) -> Self {
126- self . _arg ( optional_multi_opt ( "bin" , "NAME" , bin) )
127- . _arg ( flag ( "bins" , bins) )
128- . _arg ( optional_multi_opt ( "example" , "NAME" , example) )
129- . _arg ( flag ( "examples" , examples) )
145+ self . _arg ( optional_multi_opt ( "bin" , "NAME" , bin) . help_heading ( heading:: TARGET_SELECTION ) )
146+ . _arg ( flag ( "bins" , bins) . help_heading ( heading:: TARGET_SELECTION ) )
147+ . _arg (
148+ optional_multi_opt ( "example" , "NAME" , example)
149+ . help_heading ( heading:: TARGET_SELECTION ) ,
150+ )
151+ . _arg ( flag ( "examples" , examples) . help_heading ( heading:: TARGET_SELECTION ) )
130152 }
131153
132154 fn arg_targets_bin_example ( self , bin : & ' static str , example : & ' static str ) -> Self {
133- self . _arg ( optional_multi_opt ( "bin" , "NAME" , bin) )
134- . _arg ( optional_multi_opt ( "example" , "NAME" , example) )
155+ self . _arg ( optional_multi_opt ( "bin" , "NAME" , bin) . help_heading ( heading:: TARGET_SELECTION ) )
156+ . _arg (
157+ optional_multi_opt ( "example" , "NAME" , example)
158+ . help_heading ( heading:: TARGET_SELECTION ) ,
159+ )
135160 }
136161
137162 fn arg_features ( self ) -> Self {
@@ -141,34 +166,51 @@ pub trait CommandExt: Sized {
141166 "FEATURES" ,
142167 "Space or comma separated list of features to activate" ,
143168 )
144- . short ( 'F' ) ,
169+ . short ( 'F' )
170+ . help_heading ( heading:: FEATURE_SELECTION ) ,
171+ )
172+ . _arg (
173+ flag ( "all-features" , "Activate all available features" )
174+ . help_heading ( heading:: FEATURE_SELECTION ) ,
175+ )
176+ . _arg (
177+ flag (
178+ "no-default-features" ,
179+ "Do not activate the `default` feature" ,
180+ )
181+ . help_heading ( heading:: FEATURE_SELECTION ) ,
145182 )
146- . _arg ( flag ( "all-features" , "Activate all available features" ) )
147- . _arg ( flag (
148- "no-default-features" ,
149- "Do not activate the `default` feature" ,
150- ) )
151183 }
152184
153185 fn arg_release ( self , release : & ' static str ) -> Self {
154- self . _arg ( flag ( "release" , release) . short ( 'r' ) )
186+ self . _arg (
187+ flag ( "release" , release)
188+ . short ( 'r' )
189+ . help_heading ( heading:: COMPILATION_OPTIONS ) ,
190+ )
155191 }
156192
157193 fn arg_profile ( self , profile : & ' static str ) -> Self {
158- self . _arg ( opt ( "profile" , profile) . value_name ( "PROFILE-NAME" ) )
194+ self . _arg (
195+ opt ( "profile" , profile)
196+ . value_name ( "PROFILE-NAME" )
197+ . help_heading ( heading:: COMPILATION_OPTIONS ) ,
198+ )
159199 }
160200
161201 fn arg_doc ( self , doc : & ' static str ) -> Self {
162202 self . _arg ( flag ( "doc" , doc) )
163203 }
164204
165205 fn arg_target_triple ( self , target : & ' static str ) -> Self {
166- self . _arg ( multi_opt ( "target" , "TRIPLE" , target) )
206+ self . _arg ( multi_opt ( "target" , "TRIPLE" , target) . help_heading ( heading :: COMPILATION_OPTIONS ) )
167207 }
168208
169209 fn arg_target_dir ( self ) -> Self {
170210 self . _arg (
171- opt ( "target-dir" , "Directory for all generated artifacts" ) . value_name ( "DIRECTORY" ) ,
211+ opt ( "target-dir" , "Directory for all generated artifacts" )
212+ . value_name ( "DIRECTORY" )
213+ . help_heading ( heading:: COMPILATION_OPTIONS ) ,
172214 )
173215 }
174216
0 commit comments