Skip to content

Commit 21a4acf

Browse files
unify handling of hiding options.
1 parent 344cc9f commit 21a4acf

File tree

1 file changed

+41
-21
lines changed

1 file changed

+41
-21
lines changed

src/planet_auth_utils/commands/cli/options.py

Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
_click_option_decorator_type = Callable[..., Any]
2424

2525

26-
# TODO: make default, hidden, required params for everyone. Fix monkey patching, if needed
27-
def opt_api_key(default=None) -> _click_option_decorator_type:
26+
# TODO: Should we make "required" param universal for all options?
27+
def opt_api_key(default=None, hidden=False) -> _click_option_decorator_type:
2828
"""
2929
Click option for specifying an API key
3030
"""
@@ -38,13 +38,14 @@ def decorator(function) -> _click_option_decorator_type:
3838
default=default,
3939
show_envvar=True,
4040
show_default=True,
41+
hidden=hidden,
4142
)(function)
4243
return function
4344

4445
return decorator
4546

4647

47-
def opt_audience(default=None, required=False) -> _click_option_decorator_type:
48+
def opt_audience(default=None, hidden=False, required=False) -> _click_option_decorator_type:
4849
"""
4950
Click option for specifying an OAuth token audience for the
5051
planet_auth package's click commands.
@@ -63,13 +64,14 @@ def decorator(function) -> _click_option_decorator_type:
6364
show_envvar=True,
6465
show_default=True,
6566
required=required,
67+
hidden=hidden,
6668
)(function)
6769
return function
6870

6971
return decorator
7072

7173

72-
def opt_client_id(default=None) -> _click_option_decorator_type:
74+
def opt_client_id(default=None, hidden=False) -> _click_option_decorator_type:
7375
"""
7476
Click option for specifying an OAuth client ID.
7577
"""
@@ -83,13 +85,14 @@ def decorator(function) -> _click_option_decorator_type:
8385
default=default,
8486
show_envvar=True,
8587
show_default=True,
88+
hidden=hidden,
8689
)(function)
8790
return function
8891

8992
return decorator
9093

9194

92-
def opt_client_secret(default=None) -> _click_option_decorator_type:
95+
def opt_client_secret(default=None, hidden=False) -> _click_option_decorator_type:
9396
"""
9497
Click option for specifying an OAuth client secret.
9598
"""
@@ -103,13 +106,14 @@ def decorator(function) -> _click_option_decorator_type:
103106
default=default,
104107
show_envvar=True,
105108
show_default=True,
109+
hidden=hidden,
106110
)(function)
107111
return function
108112

109113
return decorator
110114

111115

112-
def opt_extra(default=None) -> _click_option_decorator_type:
116+
def opt_extra(default=None, hidden=False) -> _click_option_decorator_type:
113117
"""
114118
Click option for specifying extra options.
115119
"""
@@ -128,13 +132,14 @@ def decorator(function) -> _click_option_decorator_type:
128132
default=default,
129133
show_envvar=True,
130134
show_default=True,
135+
hidden=hidden,
131136
)(function)
132137
return function
133138

134139
return decorator
135140

136141

137-
def opt_human_readable(default=False) -> _click_option_decorator_type:
142+
def opt_human_readable(default=False, hidden=False) -> _click_option_decorator_type:
138143
"""
139144
Click option to toggle raw / human-readable formatting.
140145
"""
@@ -146,13 +151,14 @@ def decorator(function) -> _click_option_decorator_type:
146151
help="Reformat fields to be human readable.",
147152
default=default,
148153
show_default=True,
154+
hidden=hidden,
149155
)(function)
150156
return function
151157

152158
return decorator
153159

154160

155-
def opt_issuer(default=None, required=False) -> _click_option_decorator_type:
161+
def opt_issuer(default=None, hidden=False, required=False) -> _click_option_decorator_type:
156162
"""
157163
Click option for specifying an OAuth token issuer for the
158164
planet_auth package's click commands.
@@ -168,13 +174,14 @@ def decorator(function) -> _click_option_decorator_type:
168174
show_envvar=False,
169175
show_default=False,
170176
required=required,
177+
hidden=hidden,
171178
)(function)
172179
return function
173180

174181
return decorator
175182

176183

177-
def opt_loglevel(default="INFO") -> _click_option_decorator_type:
184+
def opt_loglevel(default="INFO", hidden=False) -> _click_option_decorator_type:
178185
"""
179186
Click option for specifying a log level.
180187
"""
@@ -189,13 +196,14 @@ def decorator(function) -> _click_option_decorator_type:
189196
default=default,
190197
show_envvar=True,
191198
show_default=True,
199+
hidden=hidden,
192200
)(function)
193201
return function
194202

195203
return decorator
196204

197205

198-
def opt_long(default=False) -> _click_option_decorator_type:
206+
def opt_long(default=False, hidden=False) -> _click_option_decorator_type:
199207
"""
200208
Click option specifying that long or more detailed output should be produced.
201209
"""
@@ -208,13 +216,14 @@ def decorator(function) -> _click_option_decorator_type:
208216
is_flag=True,
209217
default=default,
210218
show_default=True,
219+
hidden=hidden,
211220
)(function)
212221
return function
213222

214223
return decorator
215224

216225

217-
def opt_open_browser(default=True) -> _click_option_decorator_type:
226+
def opt_open_browser(default=True, hidden=False) -> _click_option_decorator_type:
218227
"""
219228
Click option for specifying whether or not opening a browser is permitted
220229
for the planet_auth package's click commands.
@@ -226,13 +235,14 @@ def decorator(function) -> _click_option_decorator_type:
226235
help="Allow/Suppress the automatic opening of a browser window.",
227236
default=default,
228237
show_default=True,
238+
hidden=hidden,
229239
)(function)
230240
return function
231241

232242
return decorator
233243

234244

235-
def opt_organization(default=None) -> _click_option_decorator_type:
245+
def opt_organization(default=None, hidden=False) -> _click_option_decorator_type:
236246
"""
237247
Click option for specifying an Organization.
238248
"""
@@ -248,6 +258,7 @@ def decorator(function) -> _click_option_decorator_type:
248258
default=default,
249259
show_envvar=True,
250260
show_default=True,
261+
hidden=hidden,
251262
)(function)
252263
return function
253264

@@ -281,7 +292,7 @@ def decorator(function) -> _click_option_decorator_type:
281292
return decorator
282293

283294

284-
def opt_profile(default=None) -> _click_option_decorator_type:
295+
def opt_profile(default=None, hidden=False) -> _click_option_decorator_type:
285296
"""
286297
Click option for specifying an auth profile for the
287298
planet_auth package's click commands.
@@ -304,13 +315,14 @@ def decorator(function) -> _click_option_decorator_type:
304315
show_envvar=True,
305316
show_default=True,
306317
is_eager=True,
318+
hidden=hidden,
307319
)(function)
308320
return function
309321

310322
return decorator
311323

312324

313-
def opt_project(default=None) -> _click_option_decorator_type:
325+
def opt_project(default=None, hidden=False) -> _click_option_decorator_type:
314326
"""
315327
Click option for specifying a project ID.
316328
"""
@@ -326,13 +338,14 @@ def decorator(function) -> _click_option_decorator_type:
326338
default=default,
327339
show_envvar=True,
328340
show_default=True,
341+
hidden=hidden,
329342
)(function)
330343
return function
331344

332345
return decorator
333346

334347

335-
def opt_qr_code(default=False) -> _click_option_decorator_type:
348+
def opt_qr_code(default=False, hidden=False) -> _click_option_decorator_type:
336349
"""
337350
Click option for specifying whether a QR code should be displayed.
338351
"""
@@ -343,13 +356,14 @@ def decorator(function) -> _click_option_decorator_type:
343356
help="Control whether a QR code is displayed for the user.",
344357
default=default,
345358
show_default=True,
359+
hidden=hidden,
346360
)(function)
347361
return function
348362

349363
return decorator
350364

351365

352-
def opt_refresh(default=True) -> _click_option_decorator_type:
366+
def opt_refresh(default=True, hidden=False) -> _click_option_decorator_type:
353367
"""
354368
Click option specifying a refresh should be attempted if applicable.
355369
"""
@@ -360,13 +374,14 @@ def decorator(function) -> _click_option_decorator_type:
360374
help="Automatically perform a credential refresh if required.",
361375
default=default,
362376
show_default=True,
377+
hidden=hidden,
363378
)(function)
364379
return function
365380

366381
return decorator
367382

368383

369-
def opt_token(default=None) -> _click_option_decorator_type:
384+
def opt_token(default=None, hidden=False) -> _click_option_decorator_type:
370385
"""
371386
Click option for specifying a token literal.
372387
"""
@@ -380,13 +395,14 @@ def decorator(function) -> _click_option_decorator_type:
380395
# envvar=EnvironmentVariables.AUTH_TOKEN,
381396
show_envvar=False,
382397
show_default=False,
398+
hidden=hidden,
383399
)(function)
384400
return function
385401

386402
return decorator
387403

388404

389-
def opt_scope(default=None) -> _click_option_decorator_type:
405+
def opt_scope(default=None, hidden=False) -> _click_option_decorator_type:
390406
"""
391407
Click option for specifying an OAuth token scope for the
392408
planet_auth package's click commands.
@@ -405,13 +421,14 @@ def decorator(function) -> _click_option_decorator_type:
405421
default=default,
406422
show_envvar=True,
407423
show_default=True,
424+
hidden=hidden,
408425
)(function)
409426
return function
410427

411428
return decorator
412429

413430

414-
def opt_sops(default=False) -> _click_option_decorator_type:
431+
def opt_sops(default=False, hidden=False) -> _click_option_decorator_type:
415432
"""
416433
Click option specifying that SOPS should be used.
417434
"""
@@ -423,13 +440,14 @@ def decorator(function) -> _click_option_decorator_type:
423440
" The environment must be configured for SOPS to work by default.",
424441
default=default,
425442
show_default=True,
443+
hidden=hidden,
426444
)(function)
427445
return function
428446

429447
return decorator
430448

431449

432-
def opt_token_file(default=None) -> _click_option_decorator_type:
450+
def opt_token_file(default=None, hidden=False) -> _click_option_decorator_type:
433451
"""
434452
Click option for specifying a token file location for the
435453
planet_auth package's click commands.
@@ -444,6 +462,7 @@ def decorator(function) -> _click_option_decorator_type:
444462
default=default,
445463
show_envvar=False,
446464
show_default=True,
465+
hidden=hidden,
447466
)(function)
448467
return function
449468

@@ -473,7 +492,7 @@ def decorator(function) -> _click_option_decorator_type:
473492
return decorator
474493

475494

476-
def opt_yes_no(default=None) -> _click_option_decorator_type:
495+
def opt_yes_no(default=None, hidden=False) -> _click_option_decorator_type:
477496
"""
478497
Click option to bypass prompts with a yes or no selection.
479498
"""
@@ -485,6 +504,7 @@ def decorator(function) -> _click_option_decorator_type:
485504
help='Skip user prompts with a "yes" or "no" selection',
486505
default=default,
487506
show_default=True,
507+
hidden=hidden,
488508
)(function)
489509
return function
490510

0 commit comments

Comments
 (0)