@@ -34,18 +34,6 @@ struct Args {
34
34
) ]
35
35
config : Option < PathBuf > ,
36
36
37
- #[ arg( long, help = "Don't pass the resulting bundle through the formatter." ) ]
38
- no_format : bool ,
39
-
40
- #[ arg(
41
- long,
42
- help = "Code formatter executable." ,
43
- long_help = "Code formatter. Must format the code from stdin and write it to stdout." ,
44
- value_name = "exe" ,
45
- default_value = DEFAULT_FORMATTER
46
- ) ]
47
- formatter : PathBuf ,
48
-
49
37
#[ arg( long = "deterministic" , help = "Output a deterministic bundle." ) ]
50
38
deterministic : bool ,
51
39
@@ -58,13 +46,29 @@ struct Args {
58
46
) ]
59
47
output_file : PathBuf ,
60
48
49
+ #[ arg( long, help = "Don't output the banner at the top of the bundle." ) ]
50
+ no_banner : bool ,
51
+
52
+ #[ arg( long, help = "Don't pass the resulting bundle through the formatter." ) ]
53
+ no_format : bool ,
54
+
55
+ #[ arg(
56
+ long,
57
+ help = "Code formatter executable." ,
58
+ long_help = "Code formatter. Must format the code from stdin and write it to stdout." ,
59
+ value_name = "exe" ,
60
+ default_value = DEFAULT_FORMATTER
61
+ ) ]
62
+ formatter : PathBuf ,
63
+
61
64
#[ arg( help = "Path to the entry source file." , value_name = "path" ) ]
62
65
entry : PathBuf ,
63
66
}
64
67
65
68
#[ derive( Debug , Clone , Deserialize ) ]
66
69
struct File {
67
70
bundle : Option < BundleSection > ,
71
+ banner : Option < BannerSection > ,
68
72
formatter : Option < FormatterSection > ,
69
73
}
70
74
@@ -76,6 +80,11 @@ struct BundleSection {
76
80
output_file : Option < PathBuf > ,
77
81
}
78
82
83
+ #[ derive( Debug , Clone , Deserialize ) ]
84
+ struct BannerSection {
85
+ enable : Option < bool > ,
86
+ }
87
+
79
88
#[ derive( Debug , Clone , Deserialize ) ]
80
89
struct FormatterSection {
81
90
enable : Option < bool > ,
@@ -148,10 +157,14 @@ impl ArgMatchesExt for ArgMatches {
148
157
149
158
#[ derive( Debug , Clone ) ]
150
159
pub struct Config {
151
- pub no_format : bool ,
152
- pub formatter : PathBuf ,
153
160
pub deterministic : bool ,
154
161
pub output_file : Option < PathBuf > ,
162
+
163
+ pub no_banner : bool ,
164
+
165
+ pub no_format : bool ,
166
+ pub formatter : PathBuf ,
167
+
155
168
pub entry : PathBuf ,
156
169
}
157
170
@@ -171,27 +184,6 @@ impl Config {
171
184
File :: read_many ( DEFAULT_CONFIG_FILES . iter ( ) . copied ( ) . map ( Path :: new) )
172
185
} ;
173
186
174
- let no_format = args
175
- . flag ( "no_format" )
176
- . or_else ( || {
177
- file. as_ref ( )
178
- . and_then ( |x| x. formatter . as_ref ( ) )
179
- . and_then ( |x| x. enable )
180
- . map ( |x| !x)
181
- } )
182
- . unwrap_or ( false ) ;
183
-
184
- let formatter = args
185
- . value :: < PathBuf > ( "formatter" )
186
- . cloned ( )
187
- . or_else ( || {
188
- file. as_ref ( )
189
- . and_then ( |x| x. formatter . as_ref ( ) )
190
- . and_then ( |x| x. path . as_ref ( ) )
191
- . cloned ( )
192
- } )
193
- . unwrap_or_else ( || PathBuf :: from ( DEFAULT_FORMATTER ) ) ;
194
-
195
187
let deterministic = args
196
188
. flag ( "deterministic" )
197
189
. or_else ( || {
@@ -215,13 +207,47 @@ impl Config {
215
207
} )
216
208
. unwrap_or ( None ) ;
217
209
210
+ let no_banner = args
211
+ . flag ( "no_banner" )
212
+ . or_else ( || {
213
+ file. as_ref ( )
214
+ . and_then ( |x| x. banner . as_ref ( ) )
215
+ . and_then ( |x| x. enable )
216
+ } )
217
+ . unwrap_or ( false ) ;
218
+
219
+ let no_format = args
220
+ . flag ( "no_format" )
221
+ . or_else ( || {
222
+ file. as_ref ( )
223
+ . and_then ( |x| x. formatter . as_ref ( ) )
224
+ . and_then ( |x| x. enable )
225
+ . map ( |x| !x)
226
+ } )
227
+ . unwrap_or ( false ) ;
228
+
229
+ let formatter = args
230
+ . value :: < PathBuf > ( "formatter" )
231
+ . cloned ( )
232
+ . or_else ( || {
233
+ file. as_ref ( )
234
+ . and_then ( |x| x. formatter . as_ref ( ) )
235
+ . and_then ( |x| x. path . as_ref ( ) )
236
+ . cloned ( )
237
+ } )
238
+ . unwrap_or_else ( || PathBuf :: from ( DEFAULT_FORMATTER ) ) ;
239
+
218
240
let entry = args. value :: < PathBuf > ( "entry" ) . unwrap ( ) . clone ( ) ;
219
241
220
242
Ok ( Self {
221
- no_format,
222
- formatter,
223
243
deterministic,
224
244
output_file,
245
+
246
+ no_banner,
247
+
248
+ no_format,
249
+ formatter,
250
+
225
251
entry,
226
252
} )
227
253
}
0 commit comments