@@ -40,7 +40,6 @@ pub struct Cli {
40
40
}
41
41
42
42
impl Cli {
43
- /// Build `Options` from command line arguments.
44
43
pub fn new ( ) -> Result < Self > {
45
44
#[ cfg( not( windows) ) ]
46
45
let possible_backends = [ "kitty" , "iterm" , "sixel" ] ;
@@ -59,8 +58,8 @@ impl Cli {
59
58
Arg :: with_name ( "input" )
60
59
. default_value ( "." )
61
60
. hide_default_value ( true )
62
- . help ( "Run as if onefetch was started in <input> instead of the current working directory." ,
63
- ) )
61
+ . help ( "Run as if onefetch was started in <input> instead of the current working directory." )
62
+ )
64
63
. arg (
65
64
Arg :: with_name ( "output" )
66
65
. short ( "o" )
@@ -70,13 +69,7 @@ impl Cli {
70
69
. possible_values ( & SerializationFormat :: iter ( )
71
70
. map ( |format| format. into ( ) )
72
71
. collect :: < Vec < & str > > ( ) )
73
- )
74
- . arg (
75
- Arg :: with_name ( "isotime" )
76
- . short ( "z" )
77
- . long ( "isotime" )
78
- . help ( "Outputs Onefetch with ISO 8601 formatted timestamps" )
79
- )
72
+ )
80
73
. arg (
81
74
Arg :: with_name ( "languages" )
82
75
. short ( "l" )
@@ -87,181 +80,180 @@ impl Cli {
87
80
Arg :: with_name ( "package-managers" )
88
81
. short ( "p" )
89
82
. long ( "package-managers" )
90
- . help ( "Prints out supported package managers." ) ,
91
- )
92
- . arg (
93
- Arg :: with_name ( "show-logo" )
94
- . long ( "show-logo" )
95
- . value_name ( "WHEN" )
96
- . takes_value ( true )
97
- . possible_values ( & [ "auto" , "never" , "always" ] )
98
- . default_value ( "always" )
99
- . hide_default_value ( true )
100
- . help ( "Specify when to show the logo (auto, never, *always*)." )
101
- . long_help (
102
- "Specify when to show the logo (auto, never, *always*). \n \
103
- If set to auto: the logo will be hidden if the terminal's width < 95."
104
- )
83
+ . help ( "Prints out supported package managers." ) ,
84
+ )
85
+ . arg (
86
+ Arg :: with_name ( "show-logo" )
87
+ . long ( "show-logo" )
88
+ . value_name ( "WHEN" )
89
+ . takes_value ( true )
90
+ . possible_values ( & [ "auto" , "never" , "always" ] )
91
+ . default_value ( "always" )
92
+ . hide_default_value ( true )
93
+ . help ( "Specify when to show the logo (auto, never, *always*)." )
94
+ . long_help (
95
+ "Specify when to show the logo (auto, never, *always*). \n \
96
+ If set to auto: the logo will be hidden if the terminal's width < 95.")
105
97
)
106
98
. arg (
107
99
Arg :: with_name ( "image" )
108
- . short ( "i" )
109
- . long ( "image" )
110
- . value_name ( "IMAGE" )
111
- . takes_value ( true )
112
- . help ( "Path to the IMAGE file." ) ,
100
+ . short ( "i" )
101
+ . long ( "image" )
102
+ . value_name ( "IMAGE" )
103
+ . takes_value ( true )
104
+ . help ( "Path to the IMAGE file." ) ,
113
105
)
114
106
. arg (
115
107
Arg :: with_name ( "image-backend" )
116
- . long ( "image-backend" )
117
- . value_name ( "BACKEND" )
118
- . takes_value ( true )
119
- . requires ( "image" )
120
- . possible_values ( & possible_backends)
121
- . help ( "Which image BACKEND to use." ) ,
108
+ . long ( "image-backend" )
109
+ . value_name ( "BACKEND" )
110
+ . takes_value ( true )
111
+ . requires ( "image" )
112
+ . possible_values ( & possible_backends)
113
+ . help ( "Which image BACKEND to use." ) ,
122
114
)
123
115
. arg (
124
116
Arg :: with_name ( "color-resolution" )
125
- . long ( "color-resolution" )
126
- . value_name ( "VALUE" )
127
- . requires ( "image" )
128
- . takes_value ( true )
129
- . possible_values ( & [ "16" , "32" , "64" , "128" , "256" ] )
130
- . help ( "VALUE of color resolution to use with SIXEL backend." ) ,
117
+ . long ( "color-resolution" )
118
+ . value_name ( "VALUE" )
119
+ . requires ( "image" )
120
+ . takes_value ( true )
121
+ . possible_values ( & [ "16" , "32" , "64" , "128" , "256" ] )
122
+ . help ( "VALUE of color resolution to use with SIXEL backend." ) ,
131
123
)
132
124
. arg (
133
125
Arg :: with_name ( "ascii-language" )
134
- . short ( "a" )
135
- . value_name ( "LANGUAGE" )
136
- . long ( "ascii-language" )
137
- . takes_value ( true )
138
- . case_insensitive ( true )
139
- . help ( "Which LANGUAGE's ascii art to print." )
140
- . possible_values (
141
- & Language :: iter ( )
142
- . map ( |language| language. into ( ) )
143
- . collect :: < Vec < & str > > ( )
144
- ) ,
126
+ . short ( "a" )
127
+ . value_name ( "LANGUAGE" )
128
+ . long ( "ascii-language" )
129
+ . takes_value ( true )
130
+ . case_insensitive ( true )
131
+ . help ( "Which LANGUAGE's ascii art to print." )
132
+ . possible_values (
133
+ & Language :: iter ( )
134
+ . map ( |language| language. into ( ) )
135
+ . collect :: < Vec < & str > > ( ) )
145
136
)
146
137
. arg (
147
138
Arg :: with_name ( "ascii-input" )
148
- . long ( "ascii-input" )
149
- . value_name ( "STRING" )
150
- . takes_value ( true )
151
- . help ( "Takes a non-empty STRING as input to replace the ASCII logo." )
152
- . long_help (
153
- "Takes a non-empty STRING as input to replace the ASCII logo. \
154
- It is possible to pass a generated STRING by command substitution. \n \
155
- For example:\n \
156
- '--ascii-input \" $(fortune | cowsay -W 25)\" '"
157
- )
158
- . validator (
159
- |t| {
160
- if t. is_empty ( ) {
161
- return Err ( String :: from ( "must not be empty" ) ) ;
162
- }
163
- Ok ( ( ) )
164
- } ,
165
- ) ,
139
+ . long ( "ascii-input" )
140
+ . value_name ( "STRING" )
141
+ . takes_value ( true )
142
+ . help ( "Takes a non-empty STRING as input to replace the ASCII logo." )
143
+ . long_help (
144
+ "Takes a non-empty STRING as input to replace the ASCII logo. \
145
+ It is possible to pass a generated STRING by command substitution. \n \
146
+ For example:\n \
147
+ '--ascii-input \" $(fortune | cowsay -W 25)\" '")
148
+ . validator (
149
+ |t| {
150
+ if t. is_empty ( ) {
151
+ return Err ( String :: from ( "must not be empty" ) ) ;
152
+ }
153
+ Ok ( ( ) )
154
+ } ,
155
+ ) ,
166
156
)
167
157
. arg (
168
158
Arg :: with_name ( "ascii-colors" )
169
- . short ( "c" )
170
- . long ( "ascii-colors" )
171
- . value_name ( "X" )
172
- . multiple ( true )
173
- . takes_value ( true )
174
- . possible_values ( color_values)
175
- . help ( "Colors (X X X...) to print the ascii art." ) ,
159
+ . short ( "c" )
160
+ . long ( "ascii-colors" )
161
+ . value_name ( "X" )
162
+ . multiple ( true )
163
+ . takes_value ( true )
164
+ . possible_values ( color_values)
165
+ . help ( "Colors (X X X...) to print the ascii art." ) ,
176
166
)
177
167
. arg (
178
168
Arg :: with_name ( "true-color" )
179
- . long ( "true-color" )
180
- . value_name ( "WHEN" )
181
- . takes_value ( true )
182
- . possible_values ( & [ "auto" , "never" , "always" ] )
183
- . default_value ( "auto" )
184
- . hide_default_value ( true )
185
- . help ( "Specify when to use true color (*auto*, never, always)." )
186
- . long_help (
187
- "Specify when to use true color (*auto*, never, always). \n \
188
- If set to auto: true color will be enabled if supported by the terminal."
189
- )
169
+ . long ( "true-color" )
170
+ . value_name ( "WHEN" )
171
+ . takes_value ( true )
172
+ . possible_values ( & [ "auto" , "never" , "always" ] )
173
+ . default_value ( "auto" )
174
+ . hide_default_value ( true )
175
+ . help ( "Specify when to use true color (*auto*, never, always)." )
176
+ . long_help (
177
+ "Specify when to use true color (*auto*, never, always). \n \
178
+ If set to auto: true color will be enabled if supported by the terminal.")
190
179
)
191
180
. arg (
192
181
Arg :: with_name ( "text-colors" )
193
- . short ( "t" )
194
- . long ( "text-colors" )
195
- . value_name ( "X" )
196
- . multiple ( true )
197
- . takes_value ( true )
198
- . max_values ( 6 )
199
- . possible_values ( color_values)
200
- . help ( "Changes the text colors (X X X...)." )
201
- . long_help (
202
- "Changes the text colors (X X X...). \
203
- Goes in order of title, ~, underline, subtitle, colon, and info. \n \
204
- For example:\n \
205
- '--text-colors 9 10 11 12 13 14'"
206
- )
182
+ . short ( "t" )
183
+ . long ( "text-colors" )
184
+ . value_name ( "X" )
185
+ . multiple ( true )
186
+ . takes_value ( true )
187
+ . max_values ( 6 )
188
+ . possible_values ( color_values)
189
+ . help ( "Changes the text colors (X X X...)." )
190
+ . long_help (
191
+ "Changes the text colors (X X X...). \
192
+ Goes in order of title, ~, underline, subtitle, colon, and info. \n \
193
+ For example:\n \
194
+ '--text-colors 9 10 11 12 13 14'")
207
195
)
208
196
. arg (
209
197
Arg :: with_name ( "no-bold" )
210
- . long ( "no-bold" )
211
- . help ( "Turns off bold formatting." ) ,
198
+ . long ( "no-bold" )
199
+ . help ( "Turns off bold formatting." ) ,
212
200
)
213
201
. arg (
214
202
Arg :: with_name ( "no-color-palette" )
215
- . long ( "no-color-palette" )
216
- . help ( "Hides the color palette." ) ,
203
+ . long ( "no-color-palette" )
204
+ . help ( "Hides the color palette." ) ,
217
205
)
218
206
. arg (
219
207
Arg :: with_name ( "no-merge-commits" )
220
- . long ( "no-merge-commits" )
221
- . help ( "Ignores merge commits." ) ,
208
+ . long ( "no-merge-commits" )
209
+ . help ( "Ignores merge commits." ) ,
210
+ )
211
+ . arg (
212
+ Arg :: with_name ( "isotime" )
213
+ . short ( "z" )
214
+ . long ( "isotime" )
215
+ . help ( "Use ISO 8601 formatted timestamps." )
222
216
)
223
217
. arg (
224
218
Arg :: with_name ( "disable-fields" )
225
- . long ( "disable-fields" )
226
- . short ( "d" )
227
- . value_name ( "FIELD" )
228
- . multiple ( true )
229
- . takes_value ( true )
230
- . case_insensitive ( true )
231
- . help ( "Allows you to disable FIELD(s) from appearing in the output." )
232
- . possible_values (
233
- & InfoField :: iter ( )
234
- . map ( |field| field. into ( ) )
235
- . collect :: < Vec < & str > > ( )
236
- ) ,
219
+ . long ( "disable-fields" )
220
+ . short ( "d" )
221
+ . value_name ( "FIELD" )
222
+ . multiple ( true )
223
+ . takes_value ( true )
224
+ . case_insensitive ( true )
225
+ . help ( "Allows you to disable FIELD(s) from appearing in the output." )
226
+ . possible_values (
227
+ & InfoField :: iter ( )
228
+ . map ( |field| field. into ( ) )
229
+ . collect :: < Vec < & str > > ( ) )
237
230
)
238
231
. arg (
239
232
Arg :: with_name ( "authors-number" )
240
- . short ( "A" )
241
- . long ( "authors-number" )
242
- . value_name ( "NUM" )
243
- . takes_value ( true )
244
- . default_value ( "3" )
245
- . help ( "NUM of authors to be shown." )
246
- . validator (
247
- |t| {
248
- t. parse :: < u32 > ( )
249
- . map_err ( |_t| "must be a number" )
250
- . map ( |_t|( ) )
251
- . map_err ( |e| e. to_string ( ) )
252
- } ,
253
- )
233
+ . short ( "A" )
234
+ . long ( "authors-number" )
235
+ . value_name ( "NUM" )
236
+ . takes_value ( true )
237
+ . default_value ( "3" )
238
+ . help ( "NUM of authors to be shown." )
239
+ . validator (
240
+ |t| {
241
+ t. parse :: < u32 > ( )
242
+ . map_err ( |_t| "must be a number" )
243
+ . map ( |_t|( ) )
244
+ . map_err ( |e| e. to_string ( ) )
245
+ } )
254
246
)
255
247
. arg (
256
248
Arg :: with_name ( "exclude" )
257
- . short ( "e" )
258
- . long ( "exclude" )
259
- . value_name ( "EXCLUDE" )
260
- . multiple ( true )
261
- . takes_value ( true )
262
- . help ( "Ignore all files & directories matching EXCLUDE." ) ,
263
- )
264
- . get_matches ( ) ;
249
+ . short ( "e" )
250
+ . long ( "exclude" )
251
+ . value_name ( "EXCLUDE" )
252
+ . multiple ( true )
253
+ . takes_value ( true )
254
+ . help ( "Ignore all files & directories matching EXCLUDE." ) ,
255
+ )
256
+ . get_matches ( ) ;
265
257
266
258
let true_color = match matches. value_of ( "true-color" ) {
267
259
Some ( "always" ) => true ,
0 commit comments