@@ -93,88 +93,91 @@ pub fn parse<I, S>(args: I) -> Result
93
93
. about ( "A tool that helps iOS developers to manage mobileprovision files." )
94
94
. version ( crate_version ! ( ) )
95
95
. subcommand ( SubCommand :: with_name ( "list" )
96
- . about ( "Lists provisioning profiles" )
97
- . display_order ( 0 )
98
- . setting ( AppSettings :: DisableVersion )
99
- . arg ( Arg :: with_name ( "TEXT" )
100
- . long ( "text" )
101
- . short ( "t" )
102
- . help ( "Lists provisioning profiles that contain this text" )
103
- . display_order ( 0 )
104
- . required ( false )
105
- . empty_values ( false )
106
- . takes_value ( true ) )
107
- . arg ( Arg :: with_name ( "DAYS" )
108
- . long ( "expire-in-days" )
109
- . short ( "d" )
110
- . help ( "Lists provisioning profiles that will expire in days" )
111
- . display_order ( 1 )
112
- . required ( false )
113
- . empty_values ( false )
114
- . takes_value ( true ) )
115
- . arg ( Arg :: with_name ( "DIRECTORY" )
116
- . long ( "source" )
117
- . help ( "A directory where to search provisioning profiles" )
118
- . required ( false )
119
- . empty_values ( false )
120
- . takes_value ( true ) ) )
96
+ . about ( "Lists provisioning profiles" )
97
+ . display_order ( 0 )
98
+ . setting ( AppSettings :: DisableVersion )
99
+ . arg ( Arg :: with_name ( "TEXT" )
100
+ . long ( "text" )
101
+ . short ( "t" )
102
+ . help ( "Lists provisioning profiles that contain this text" )
103
+ . display_order ( 0 )
104
+ . required ( false )
105
+ . empty_values ( false )
106
+ . takes_value ( true ) )
107
+ . arg ( Arg :: with_name ( "DAYS" )
108
+ . long ( "expire-in-days" )
109
+ . short ( "d" )
110
+ . help ( "Lists provisioning profiles that will expire in days" )
111
+ . display_order ( 1 )
112
+ . required ( false )
113
+ . empty_values ( false )
114
+ . takes_value ( true ) )
115
+ . arg ( Arg :: with_name ( "DIRECTORY" )
116
+ . long ( "source" )
117
+ . help ( "A directory where to search provisioning profiles" )
118
+ . required ( false )
119
+ . empty_values ( false )
120
+ . takes_value ( true ) ) )
121
121
. subcommand ( SubCommand :: with_name ( "show" )
122
- . about ( "Shows details of a provisioning profile using its uuid" )
123
- . display_order ( 1 )
124
- . setting ( AppSettings :: DisableVersion )
125
- . arg ( Arg :: with_name ( "UUID" )
126
- . help ( "An uuid of a provisioning profile" )
127
- . required ( true )
128
- . empty_values ( false )
129
- . takes_value ( true ) )
130
- . arg ( Arg :: with_name ( "DIRECTORY" )
131
- . long ( "source" )
132
- . help ( "A directory where to search a provisioning profile" )
133
- . required ( false )
134
- . empty_values ( false )
135
- . takes_value ( true ) ) )
122
+ . about ( "Shows details of a provisioning profile using its uuid" )
123
+ . display_order ( 1 )
124
+ . setting ( AppSettings :: DisableVersion )
125
+ . arg ( Arg :: with_name ( "UUID" )
126
+ . help ( "An uuid of a provisioning profile" )
127
+ . required ( true )
128
+ . empty_values ( false )
129
+ . takes_value ( true ) )
130
+ . arg ( Arg :: with_name ( "DIRECTORY" )
131
+ . long ( "source" )
132
+ . help ( "A directory where to search a provisioning profile" )
133
+ . required ( false )
134
+ . empty_values ( false )
135
+ . takes_value ( true ) ) )
136
136
. subcommand ( SubCommand :: with_name ( "show-file" )
137
- . about ( "Shows details of a provisioning profile" )
138
- . display_order ( 2 )
139
- . setting ( AppSettings :: DisableVersion )
140
- . arg ( Arg :: with_name ( "PATH" )
141
- . help ( "A file path of a provisioning profile" )
142
- . required ( true )
143
- . empty_values ( false )
144
- . takes_value ( true ) ) )
137
+ . about ( "Shows details of a provisioning profile" )
138
+ . display_order ( 2 )
139
+ . setting ( AppSettings :: DisableVersion )
140
+ . arg ( Arg :: with_name ( "PATH" )
141
+ . help ( "A file path of a provisioning profile" )
142
+ . required ( true )
143
+ . empty_values ( false )
144
+ . takes_value ( true ) ) )
145
145
. subcommand ( SubCommand :: with_name ( "remove" )
146
- . about ( "Removes a provisioning profile" )
147
- . display_order ( 3 )
148
- . setting ( AppSettings :: DisableVersion )
149
- . arg ( Arg :: with_name ( "UUID" )
150
- . help ( "An uuid of a provisioning profile" )
151
- . required ( true )
152
- . empty_values ( false )
153
- . multiple ( true )
154
- . takes_value ( true ) )
155
- . arg ( Arg :: with_name ( "DIRECTORY" )
156
- . long ( "source" )
157
- . help ( "A directory where to search a provisioning profile" )
158
- . required ( false )
159
- . empty_values ( false )
160
- . takes_value ( true ) ) )
146
+ . about ( "Removes a provisioning profile" )
147
+ . display_order ( 3 )
148
+ . setting ( AppSettings :: DisableVersion )
149
+ . arg ( Arg :: with_name ( "UUID" )
150
+ . help ( "An uuid of a provisioning profile" )
151
+ . required ( true )
152
+ . empty_values ( false )
153
+ . multiple ( true )
154
+ . takes_value ( true ) )
155
+ . arg ( Arg :: with_name ( "DIRECTORY" )
156
+ . long ( "source" )
157
+ . help ( "A directory where to search a provisioning profile" )
158
+ . required ( false )
159
+ . empty_values ( false )
160
+ . takes_value ( true ) ) )
161
161
. subcommand ( SubCommand :: with_name ( "clean" )
162
- . about ( "Removes expired provisioning profiles" )
163
- . display_order ( 4 )
164
- . setting ( AppSettings :: DisableVersion )
165
- . arg ( Arg :: with_name ( "DIRECTORY" )
166
- . long ( "source" )
167
- . help ( "A directory where to clean" )
168
- . required ( false )
169
- . empty_values ( false )
170
- . takes_value ( true ) ) ) ;
162
+ . about ( "Removes expired provisioning profiles" )
163
+ . display_order ( 4 )
164
+ . setting ( AppSettings :: DisableVersion )
165
+ . arg ( Arg :: with_name ( "DIRECTORY" )
166
+ . long ( "source" )
167
+ . help ( "A directory where to clean" )
168
+ . required ( false )
169
+ . empty_values ( false )
170
+ . takes_value ( true ) ) ) ;
171
171
172
172
let matches = app. get_matches_from_safe ( args) ?;
173
173
if let Some ( list_matches) = matches. subcommand_matches ( "list" ) {
174
174
let mut params = ListParams :: default ( ) ;
175
- params. filter = list_matches. value_of ( "TEXT" ) . map ( |text| text. to_string ( ) ) ;
176
- if let Some ( days) = list_matches. value_of ( "DAYS" )
177
- . and_then ( |days| days. parse :: < i64 > ( ) . ok ( ) ) {
175
+ params. filter = list_matches
176
+ . value_of ( "TEXT" )
177
+ . map ( |text| text. to_string ( ) ) ;
178
+ if let Some ( days) = list_matches
179
+ . value_of ( "DAYS" )
180
+ . and_then ( |days| days. parse :: < i64 > ( ) . ok ( ) ) {
178
181
if days < 0 || days > 365 {
179
182
return Err ( Error :: Custom ( "DAYS should be between 0 and 365" . to_string ( ) ) ) ;
180
183
}
@@ -183,15 +186,27 @@ pub fn parse<I, S>(args: I) -> Result
183
186
params. directory = list_matches. value_of ( "DIRECTORY" ) . map ( |dir| dir. into ( ) ) ;
184
187
Ok ( Command :: List ( params) )
185
188
} else if let Some ( show_matches) = matches. subcommand_matches ( "show" ) {
186
- let uuid = show_matches. value_of ( "UUID" ) . map ( |uuid| uuid. to_string ( ) ) . unwrap ( ) ;
189
+ let uuid = show_matches
190
+ . value_of ( "UUID" )
191
+ . map ( |uuid| uuid. to_string ( ) )
192
+ . unwrap ( ) ;
187
193
let directory = show_matches. value_of ( "DIRECTORY" ) . map ( |dir| dir. into ( ) ) ;
188
194
Ok ( Command :: ShowUuid ( uuid, directory) )
189
195
} else if let Some ( show_file_matches) = matches. subcommand_matches ( "show-file" ) {
190
- let path = show_file_matches. value_of ( "PATH" ) . map ( |path| path. into ( ) ) . unwrap ( ) ;
196
+ let path = show_file_matches
197
+ . value_of ( "PATH" )
198
+ . map ( |path| path. into ( ) )
199
+ . unwrap ( ) ;
191
200
Ok ( Command :: ShowFile ( path) )
192
201
} else if let Some ( remove_matches) = matches. subcommand_matches ( "remove" ) {
193
- let uuids = remove_matches. values_of ( "UUID" ) . unwrap ( ) . map ( String :: from) . collect ( ) ;
194
- let directory = remove_matches. value_of ( "DIRECTORY" ) . map ( |dir| dir. into ( ) ) ;
202
+ let uuids = remove_matches
203
+ . values_of ( "UUID" )
204
+ . unwrap ( )
205
+ . map ( String :: from)
206
+ . collect ( ) ;
207
+ let directory = remove_matches
208
+ . value_of ( "DIRECTORY" )
209
+ . map ( |dir| dir. into ( ) ) ;
195
210
Ok ( Command :: Remove ( uuids, directory) )
196
211
} else if let Some ( clean_matches) = matches. subcommand_matches ( "clean" ) {
197
212
let directory = clean_matches. value_of ( "DIRECTORY" ) . map ( |dir| dir. into ( ) ) ;
@@ -213,42 +228,42 @@ mod tests {
213
228
214
229
expect ! ( parse( & [ "mprovision" , "list" , "--source" , "." ] ) )
215
230
. to ( be_ok ( ) . value ( Command :: List ( ListParams {
216
- filter : None ,
217
- expire_in_days : None ,
218
- directory : Some ( "." . into ( ) ) ,
219
- } ) ) ) ;
231
+ filter : None ,
232
+ expire_in_days : None ,
233
+ directory : Some ( "." . into ( ) ) ,
234
+ } ) ) ) ;
220
235
221
236
expect ! ( parse( & [ "mprovision" , "list" , "--text" , "abc" ] ) )
222
237
. to ( be_ok ( ) . value ( Command :: List ( ListParams {
223
- filter : Some ( "abc" . to_string ( ) ) ,
224
- expire_in_days : None ,
225
- directory : None ,
226
- } ) ) ) ;
238
+ filter : Some ( "abc" . to_string ( ) ) ,
239
+ expire_in_days : None ,
240
+ directory : None ,
241
+ } ) ) ) ;
227
242
228
243
expect ! ( parse( & [ "mprovision" , "list" , "-t" , "abc" ] ) )
229
244
. to ( be_ok ( ) . value ( Command :: List ( ListParams {
230
- filter : Some ( "abc" . to_string ( ) ) ,
231
- expire_in_days : None ,
232
- directory : None ,
233
- } ) ) ) ;
245
+ filter : Some ( "abc" . to_string ( ) ) ,
246
+ expire_in_days : None ,
247
+ directory : None ,
248
+ } ) ) ) ;
234
249
235
250
expect ! ( parse( & [ "mprovision" , "list" , "--text" , "" ] ) ) . to ( be_err ( ) ) ;
236
251
237
252
expect ! ( parse( & [ "mprovision" , "list" , "-t" , "" ] ) ) . to ( be_err ( ) ) ;
238
253
239
254
expect ! ( parse( & [ "mprovision" , "list" , "--expire-in-days" , "3" ] ) )
240
255
. to ( be_ok ( ) . value ( Command :: List ( ListParams {
241
- filter : None ,
242
- expire_in_days : Some ( 3 ) ,
243
- directory : None ,
244
- } ) ) ) ;
256
+ filter : None ,
257
+ expire_in_days : Some ( 3 ) ,
258
+ directory : None ,
259
+ } ) ) ) ;
245
260
246
261
expect ! ( parse( & [ "mprovision" , "list" , "-d" , "3" ] ) )
247
262
. to ( be_ok ( ) . value ( Command :: List ( ListParams {
248
- filter : None ,
249
- expire_in_days : Some ( 3 ) ,
250
- directory : None ,
251
- } ) ) ) ;
263
+ filter : None ,
264
+ expire_in_days : Some ( 3 ) ,
265
+ directory : None ,
266
+ } ) ) ) ;
252
267
253
268
expect ! ( parse( & [ "mprovision" , "list" , "--expire-in-days" , "-3" ] ) ) . to ( be_err ( ) ) ;
254
269
expect ! ( parse( & [ "mprovision" , "list" , "-d" , "-3" ] ) ) . to ( be_err ( ) ) ;
@@ -263,18 +278,25 @@ mod tests {
263
278
"3" ,
264
279
"--source" ,
265
280
"." ] ) )
266
- . to ( be_ok ( ) . value ( Command :: List ( ListParams {
267
- filter : Some ( "abc" . to_string ( ) ) ,
268
- expire_in_days : Some ( 3 ) ,
269
- directory : Some ( "." . into ( ) ) ,
270
- } ) ) ) ;
281
+ . to ( be_ok ( ) . value ( Command :: List ( ListParams {
282
+ filter : Some ( "abc" . to_string ( ) ) ,
283
+ expire_in_days : Some ( 3 ) ,
284
+ directory : Some ( "." . into ( ) ) ,
285
+ } ) ) ) ;
271
286
272
- expect ! ( parse( & [ "mprovision" , "list" , "-t" , "abc" , "-d" , "3" , "--source" , "." ] ) )
273
- . to ( be_ok ( ) . value ( Command :: List ( ListParams {
274
- filter : Some ( "abc" . to_string ( ) ) ,
275
- expire_in_days : Some ( 3 ) ,
276
- directory : Some ( "." . into ( ) ) ,
277
- } ) ) ) ;
287
+ expect ! ( parse( & [ "mprovision" ,
288
+ "list" ,
289
+ "-t" ,
290
+ "abc" ,
291
+ "-d" ,
292
+ "3" ,
293
+ "--source" ,
294
+ "." ] ) )
295
+ . to ( be_ok ( ) . value ( Command :: List ( ListParams {
296
+ filter : Some ( "abc" . to_string ( ) ) ,
297
+ expire_in_days : Some ( 3 ) ,
298
+ directory : Some ( "." . into ( ) ) ,
299
+ } ) ) ) ;
278
300
}
279
301
280
302
#[ test]
0 commit comments