@@ -107,10 +107,15 @@ enum Subcommand {
107
107
token : Option < String > ,
108
108
109
109
/// Maximum number of times this token can be used.
110
- /// If not provided, the token can be used an unlimited number of times.
111
- #[ arg( long) ]
110
+ /// If not provided, the token can be used only once, unless the
111
+ /// `--unlimited` flag is set.
112
+ #[ arg( long, group = "token-usage-limit" ) ]
112
113
usage_limit : Option < u32 > ,
113
114
115
+ /// Allow the token to be used an unlimited number of times.
116
+ #[ arg( long, action = ArgAction :: SetTrue , group = "token-usage-limit" ) ]
117
+ unlimited : bool ,
118
+
114
119
/// Time in seconds after which the token expires.
115
120
/// If not provided, the token never expires.
116
121
#[ arg( long) ]
@@ -355,10 +360,18 @@ impl Options {
355
360
SC :: IssueUserRegistrationToken {
356
361
token,
357
362
usage_limit,
363
+ unlimited,
358
364
expires_in,
359
365
} => {
360
366
let _span = info_span ! ( "cli.manage.add_user_registration_token" ) . entered ( ) ;
361
367
368
+ let usage_limit = match ( usage_limit, unlimited) {
369
+ ( Some ( usage_limit) , false ) => Some ( usage_limit) ,
370
+ ( None , false ) => Some ( 1 ) ,
371
+ ( None , true ) => None ,
372
+ ( Some ( _) , true ) => unreachable ! ( ) , // This should be handled by the clap group
373
+ } ;
374
+
362
375
let database_config = DatabaseConfig :: extract_or_default ( figment) ?;
363
376
let mut conn = database_connection_from_config ( & database_config) . await ?;
364
377
let txn = conn. begin ( ) . await ?;
0 commit comments