24
24
25
25
26
26
# TODO: make default, hidden, required params for everyone. Fix monkey patching, if needed
27
- # TODO: sort members
28
- def opt_api_key () -> _click_option_decorator_type :
27
+ def opt_api_key (default = None ) -> _click_option_decorator_type :
29
28
"""
30
29
Click option for specifying an API key
31
30
"""
@@ -36,7 +35,7 @@ def decorator(function) -> _click_option_decorator_type:
36
35
type = str ,
37
36
envvar = EnvironmentVariables .AUTH_API_KEY ,
38
37
help = "Specify an API key." ,
39
- default = None ,
38
+ default = default ,
40
39
show_envvar = True ,
41
40
show_default = True ,
42
41
)(function )
@@ -45,7 +44,7 @@ def decorator(function) -> _click_option_decorator_type:
45
44
return decorator
46
45
47
46
48
- def opt_audience (required = False ) -> _click_option_decorator_type :
47
+ def opt_audience (default = None , required = False ) -> _click_option_decorator_type :
49
48
"""
50
49
Click option for specifying an OAuth token audience for the
51
50
planet_auth package's click commands.
@@ -60,7 +59,7 @@ def decorator(function) -> _click_option_decorator_type:
60
59
help = "Token audiences. Specify multiple options to set"
61
60
" multiple audiences. When set via environment variable, audiences"
62
61
" should be white space delimited." ,
63
- default = None ,
62
+ default = default ,
64
63
show_envvar = True ,
65
64
show_default = True ,
66
65
required = required ,
@@ -70,7 +69,7 @@ def decorator(function) -> _click_option_decorator_type:
70
69
return decorator
71
70
72
71
73
- def opt_client_id () -> _click_option_decorator_type :
72
+ def opt_client_id (default = None ) -> _click_option_decorator_type :
74
73
"""
75
74
Click option for specifying an OAuth client ID.
76
75
"""
@@ -81,7 +80,7 @@ def decorator(function) -> _click_option_decorator_type:
81
80
type = str ,
82
81
envvar = EnvironmentVariables .AUTH_CLIENT_ID ,
83
82
help = "Specify the OAuth client ID." ,
84
- default = None ,
83
+ default = default ,
85
84
show_envvar = True ,
86
85
show_default = True ,
87
86
)(function )
@@ -90,7 +89,7 @@ def decorator(function) -> _click_option_decorator_type:
90
89
return decorator
91
90
92
91
93
- def opt_client_secret () -> _click_option_decorator_type :
92
+ def opt_client_secret (default = None ) -> _click_option_decorator_type :
94
93
"""
95
94
Click option for specifying an OAuth client secret.
96
95
"""
@@ -101,7 +100,7 @@ def decorator(function) -> _click_option_decorator_type:
101
100
type = str ,
102
101
envvar = EnvironmentVariables .AUTH_CLIENT_SECRET ,
103
102
help = "Specify the OAuth client Secret." ,
104
- default = None ,
103
+ default = default ,
105
104
show_envvar = True ,
106
105
show_default = True ,
107
106
)(function )
@@ -110,7 +109,7 @@ def decorator(function) -> _click_option_decorator_type:
110
109
return decorator
111
110
112
111
113
- def opt_extra () -> _click_option_decorator_type :
112
+ def opt_extra (default = None ) -> _click_option_decorator_type :
114
113
"""
115
114
Click option for specifying extra options.
116
115
"""
@@ -126,7 +125,7 @@ def decorator(function) -> _click_option_decorator_type:
126
125
" multiple extra options. The format of an option is <key>=<value>."
127
126
" When set via environment variable, values should be delimited by"
128
127
" whitespace." ,
129
- default = None ,
128
+ default = default ,
130
129
show_envvar = True ,
131
130
show_default = True ,
132
131
)(function )
@@ -135,7 +134,7 @@ def decorator(function) -> _click_option_decorator_type:
135
134
return decorator
136
135
137
136
138
- def opt_human_readable () -> _click_option_decorator_type :
137
+ def opt_human_readable (default = False ) -> _click_option_decorator_type :
139
138
"""
140
139
Click option to toggle raw / human-readable formatting.
141
140
"""
@@ -145,15 +144,15 @@ def decorator(function) -> _click_option_decorator_type:
145
144
"--human-readable/--no-human-readable" ,
146
145
"-H" ,
147
146
help = "Reformat fields to be human readable." ,
148
- default = False ,
147
+ default = default ,
149
148
show_default = True ,
150
149
)(function )
151
150
return function
152
151
153
152
return decorator
154
153
155
154
156
- def opt_issuer (required = False ) -> _click_option_decorator_type :
155
+ def opt_issuer (default = None , required = False ) -> _click_option_decorator_type :
157
156
"""
158
157
Click option for specifying an OAuth token issuer for the
159
158
planet_auth package's click commands.
@@ -165,7 +164,7 @@ def decorator(function) -> _click_option_decorator_type:
165
164
type = str ,
166
165
envvar = EnvironmentVariables .AUTH_ISSUER ,
167
166
help = "Token issuer." ,
168
- default = None ,
167
+ default = default ,
169
168
show_envvar = False ,
170
169
show_default = False ,
171
170
required = required ,
@@ -175,7 +174,7 @@ def decorator(function) -> _click_option_decorator_type:
175
174
return decorator
176
175
177
176
178
- def opt_loglevel () -> _click_option_decorator_type :
177
+ def opt_loglevel (default = "INFO" ) -> _click_option_decorator_type :
179
178
"""
180
179
Click option for specifying a log level.
181
180
"""
@@ -187,7 +186,7 @@ def decorator(function) -> _click_option_decorator_type:
187
186
envvar = EnvironmentVariables .AUTH_LOGLEVEL ,
188
187
help = "Set the log level." ,
189
188
type = click .Choice (["CRITICAL" , "ERROR" , "WARNING" , "INFO" , "DEBUG" ], case_sensitive = False ),
190
- default = "INFO" ,
189
+ default = default ,
191
190
show_envvar = True ,
192
191
show_default = True ,
193
192
)(function )
@@ -196,7 +195,7 @@ def decorator(function) -> _click_option_decorator_type:
196
195
return decorator
197
196
198
197
199
- def opt_long () -> _click_option_decorator_type :
198
+ def opt_long (default = False ) -> _click_option_decorator_type :
200
199
"""
201
200
Click option specifying that long or more detailed output should be produced.
202
201
"""
@@ -207,15 +206,15 @@ def decorator(function) -> _click_option_decorator_type:
207
206
"--long" ,
208
207
help = "Longer, more detailed output" ,
209
208
is_flag = True ,
210
- default = False ,
209
+ default = default ,
211
210
show_default = True ,
212
211
)(function )
213
212
return function
214
213
215
214
return decorator
216
215
217
216
218
- def opt_open_browser () -> _click_option_decorator_type :
217
+ def opt_open_browser (default = True ) -> _click_option_decorator_type :
219
218
"""
220
219
Click option for specifying whether or not opening a browser is permitted
221
220
for the planet_auth package's click commands.
@@ -225,7 +224,7 @@ def decorator(function) -> _click_option_decorator_type:
225
224
function = click .option (
226
225
"--open-browser/--no-open-browser" ,
227
226
help = "Allow/Suppress the automatic opening of a browser window." ,
228
- default = True ,
227
+ default = default ,
229
228
show_default = True ,
230
229
)(function )
231
230
return function
@@ -260,7 +259,7 @@ def decorator(function) -> _click_option_decorator_type:
260
259
# I generally think user IO belongs with the app, and not the the library, but since the
261
260
# lib also handles things like browser interaction this is not entirely easy to abstract
262
261
# away.
263
- def opt_password (hidden = True ) -> _click_option_decorator_type :
262
+ def opt_password (default = None , hidden = True ) -> _click_option_decorator_type :
264
263
"""
265
264
Click option for specifying a password for the
266
265
planet_auth package's click commands.
@@ -272,7 +271,7 @@ def decorator(function) -> _click_option_decorator_type:
272
271
type = str ,
273
272
envvar = EnvironmentVariables .AUTH_PASSWORD ,
274
273
help = "Password used for authentication. May not be used by all authentication mechanisms." ,
275
- default = None ,
274
+ default = default ,
276
275
show_envvar = True ,
277
276
show_default = True ,
278
277
hidden = hidden , # Primarily used by legacy auth. OAuth2 is preferred, wherein we do not handle username/password.
@@ -311,7 +310,7 @@ def decorator(function) -> _click_option_decorator_type:
311
310
return decorator
312
311
313
312
314
- def opt_project () -> _click_option_decorator_type :
313
+ def opt_project (default = None ) -> _click_option_decorator_type :
315
314
"""
316
315
Click option for specifying a project ID.
317
316
"""
@@ -324,7 +323,7 @@ def decorator(function) -> _click_option_decorator_type:
324
323
# envvar=EnvironmentVariables.AUTH_PROJECT,
325
324
help = "Project ID to use when performing authentication. When present, this option will be"
326
325
" appended to authorization requests. Not all implementations understand this option." ,
327
- default = None ,
326
+ default = default ,
328
327
show_envvar = True ,
329
328
show_default = True ,
330
329
)(function )
@@ -333,7 +332,7 @@ def decorator(function) -> _click_option_decorator_type:
333
332
return decorator
334
333
335
334
336
- def opt_qr_code () -> _click_option_decorator_type :
335
+ def opt_qr_code (default = False ) -> _click_option_decorator_type :
337
336
"""
338
337
Click option for specifying whether a QR code should be displayed.
339
338
"""
@@ -342,15 +341,15 @@ def decorator(function) -> _click_option_decorator_type:
342
341
function = click .option (
343
342
"--show-qr-code/--no-show-qr-code" ,
344
343
help = "Control whether a QR code is displayed for the user." ,
345
- default = False ,
344
+ default = default ,
346
345
show_default = True ,
347
346
)(function )
348
347
return function
349
348
350
349
return decorator
351
350
352
351
353
- def opt_refresh () -> _click_option_decorator_type :
352
+ def opt_refresh (default = True ) -> _click_option_decorator_type :
354
353
"""
355
354
Click option specifying a refresh should be attempted if applicable.
356
355
"""
@@ -359,15 +358,15 @@ def decorator(function) -> _click_option_decorator_type:
359
358
function = click .option (
360
359
"--refresh/--no-refresh" ,
361
360
help = "Automatically perform a credential refresh if required." ,
362
- default = True ,
361
+ default = default ,
363
362
show_default = True ,
364
363
)(function )
365
364
return function
366
365
367
366
return decorator
368
367
369
368
370
- def opt_token () -> _click_option_decorator_type :
369
+ def opt_token (default = None ) -> _click_option_decorator_type :
371
370
"""
372
371
Click option for specifying a token literal.
373
372
"""
@@ -376,6 +375,7 @@ def decorator(function) -> _click_option_decorator_type:
376
375
function = click .option (
377
376
"--token" ,
378
377
help = "Token string." ,
378
+ default = default ,
379
379
type = str ,
380
380
# envvar=EnvironmentVariables.AUTH_TOKEN,
381
381
show_envvar = False ,
@@ -386,7 +386,7 @@ def decorator(function) -> _click_option_decorator_type:
386
386
return decorator
387
387
388
388
389
- def opt_scope () -> _click_option_decorator_type :
389
+ def opt_scope (default = None ) -> _click_option_decorator_type :
390
390
"""
391
391
Click option for specifying an OAuth token scope for the
392
392
planet_auth package's click commands.
@@ -402,7 +402,7 @@ def decorator(function) -> _click_option_decorator_type:
402
402
" multiple scopes. When set via environment variable, scopes"
403
403
" should be white space delimited. Default value is determined"
404
404
" by the selected auth profile." ,
405
- default = None ,
405
+ default = default ,
406
406
show_envvar = True ,
407
407
show_default = True ,
408
408
)(function )
@@ -411,7 +411,7 @@ def decorator(function) -> _click_option_decorator_type:
411
411
return decorator
412
412
413
413
414
- def opt_sops () -> _click_option_decorator_type :
414
+ def opt_sops (default = False ) -> _click_option_decorator_type :
415
415
"""
416
416
Click option specifying that SOPS should be used.
417
417
"""
@@ -421,15 +421,15 @@ def decorator(function) -> _click_option_decorator_type:
421
421
"--sops/--no-sops" ,
422
422
help = "Use sops when creating new files where applicable."
423
423
" The environment must be configured for SOPS to work by default." ,
424
- default = False ,
424
+ default = default ,
425
425
show_default = True ,
426
426
)(function )
427
427
return function
428
428
429
429
return decorator
430
430
431
431
432
- def opt_token_file () -> _click_option_decorator_type :
432
+ def opt_token_file (default = None ) -> _click_option_decorator_type :
433
433
"""
434
434
Click option for specifying a token file location for the
435
435
planet_auth package's click commands.
@@ -441,7 +441,7 @@ def decorator(function) -> _click_option_decorator_type:
441
441
type = click .Path (exists = True , file_okay = True , readable = True , path_type = pathlib .Path ),
442
442
envvar = EnvironmentVariables .AUTH_TOKEN_FILE ,
443
443
help = "File containing a token." ,
444
- default = None ,
444
+ default = default ,
445
445
show_envvar = False ,
446
446
show_default = True ,
447
447
)(function )
@@ -450,7 +450,7 @@ def decorator(function) -> _click_option_decorator_type:
450
450
return decorator
451
451
452
452
453
- def opt_username (hidden = True ) -> _click_option_decorator_type :
453
+ def opt_username (default = None , hidden = True ) -> _click_option_decorator_type :
454
454
"""
455
455
Click option for specifying a username for the
456
456
planet_auth package's click commands.
@@ -463,7 +463,7 @@ def decorator(function) -> _click_option_decorator_type:
463
463
type = str ,
464
464
envvar = EnvironmentVariables .AUTH_USERNAME ,
465
465
help = "Username used for authentication. May not be used by all authentication mechanisms." ,
466
- default = None ,
466
+ default = default ,
467
467
show_envvar = True ,
468
468
show_default = True ,
469
469
hidden = hidden , # Primarily used by legacy auth. OAuth2 is preferred, wherein we do not handle username/password.
@@ -473,7 +473,7 @@ def decorator(function) -> _click_option_decorator_type:
473
473
return decorator
474
474
475
475
476
- def opt_yes_no () -> _click_option_decorator_type :
476
+ def opt_yes_no (default = None ) -> _click_option_decorator_type :
477
477
"""
478
478
Click option to bypass prompts with a yes or no selection.
479
479
"""
@@ -483,7 +483,7 @@ def decorator(function) -> _click_option_decorator_type:
483
483
"--yes/--no" ,
484
484
"-y/-n" ,
485
485
help = 'Skip user prompts with a "yes" or "no" selection' ,
486
- default = None ,
486
+ default = default ,
487
487
show_default = True ,
488
488
)(function )
489
489
return function
0 commit comments