Skip to content

Commit 083a287

Browse files
committed
[IDEV-282] bugbash: change all cli param to use dash instead of underscore.
1 parent 51143ee commit 083a287

File tree

9 files changed

+120
-115
lines changed

9 files changed

+120
-115
lines changed

domaintools/cli/api.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@
66

77
from typing import Optional, Dict, Tuple
88
from rich.progress import Progress, SpinnerColumn, TextColumn
9-
from rich import print
9+
from rich import console
1010

1111
from domaintools.api import API
1212
from domaintools.exceptions import ServiceException
1313
from domaintools.cli.utils import get_file_extension
1414

15+
console = console.Console()
16+
1517

1618
class DTCLICommand:
1719
API_SUCCESS_STATUS = 200
@@ -73,6 +75,9 @@ def args_to_dict(*args) -> Dict:
7375
for i in range(0, len(args), 2):
7476
key = args[i].replace("--", "")
7577
value = args[i + 1].strip()
78+
# replace all the "-" to "_" to make it a valid kwargs
79+
# we replace all CLI parameters to use "-" instead of underscore.
80+
key = key.replace("-", "_")
7681
argument_dict[key] = value
7782
except:
7883
pass
@@ -193,7 +198,7 @@ def run(cls, name: str, params: Optional[Dict] = {}, **kwargs):
193198

194199
if isinstance(out_file, _io.TextIOWrapper):
195200
# use rich `print` command to prettify the ouput in sys.stdout
196-
typer.echo(output)
201+
print(output)
197202
else:
198203
# if it's a file then write
199204
out_file.write(output if output.endswith("\n") else output + "\n")

domaintools/cli/commands/accounts.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def account_information(
1919
creds_file: str = typer.Option(
2020
"~/.dtapi",
2121
"-c",
22-
"--cred_file",
22+
"--credfile",
2323
help="Optional file with API username and API key, one per line.",
2424
),
2525
rate_limit: bool = typer.Option(
@@ -36,7 +36,7 @@ def account_information(
3636
callback=DTCLICommand.validate_format_input,
3737
),
3838
out_file: typer.FileTextWrite = typer.Option(
39-
sys.stdout, "-o", "--out_file", help="Output file (defaults to stdout)"
39+
sys.stdout, "-o", "--out-file", help="Output file (defaults to stdout)"
4040
),
4141
no_verify_ssl: bool = typer.Option(
4242
False,
@@ -58,7 +58,7 @@ def available_api_calls(
5858
creds_file: str = typer.Option(
5959
"~/.dtapi",
6060
"-c",
61-
"--cred_file",
61+
"--credfile",
6262
help="Optional file with API username and API key, one per line.",
6363
),
6464
rate_limit: bool = typer.Option(

domaintools/cli/commands/detects.py

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def iris_detect_monitors(
4747
creds_file: str = typer.Option(
4848
"~/.dtapi",
4949
"-c",
50-
"--cred_file",
50+
"--credfile",
5151
help="Optional file with API username and API key, one per line.",
5252
),
5353
rate_limit: bool = typer.Option(
@@ -64,7 +64,7 @@ def iris_detect_monitors(
6464
callback=DTCLICommand.validate_format_input,
6565
),
6666
out_file: typer.FileTextWrite = typer.Option(
67-
sys.stdout, "-o", "--out_file", help="Output file (defaults to stdout)"
67+
sys.stdout, "-o", "--out-file", help="Output file (defaults to stdout)"
6868
),
6969
no_verify_ssl: bool = typer.Option(
7070
False,
@@ -101,7 +101,7 @@ def iris_detect_new_domains(
101101
),
102102
discovered_since: str = typer.Option(
103103
None,
104-
"--discovered_since",
104+
"--discovered-since",
105105
help="ISO 8601 datetime format: default None. Filter domains by when they were discovered.",
106106
),
107107
changed_since: str = typer.Option(
@@ -145,13 +145,13 @@ def iris_detect_new_domains(
145145
creds_file: str = typer.Option(
146146
"~/.dtapi",
147147
"-c",
148-
"--cred_file",
148+
"--credfile",
149149
help="Optional file with API username and API key, one per line.",
150150
),
151151
rate_limit: bool = typer.Option(
152152
False,
153153
"-l",
154-
"--rate_limit",
154+
"--rate-limit",
155155
help="Rate limit API calls against the API based on per minute limits.",
156156
),
157157
format: str = typer.Option(
@@ -162,7 +162,7 @@ def iris_detect_new_domains(
162162
callback=DTCLICommand.validate_format_input,
163163
),
164164
out_file: typer.FileTextWrite = typer.Option(
165-
sys.stdout, "-o", "--out_file", help="Output file (defaults to stdout)"
165+
sys.stdout, "-o", "--out-file", help="Output file (defaults to stdout)"
166166
),
167167
no_verify_ssl: bool = typer.Option(
168168
False,
@@ -190,7 +190,7 @@ def iris_detect_watched_domains(
190190
),
191191
escalation_types: str = typer.Option(
192192
None,
193-
"--escalation_types",
193+
"--escalation-types",
194194
help="List of escalation types to filter domains by. Valid values are: {'blocked', 'google_safe'}",
195195
),
196196
escalated_since: str = typer.Option(
@@ -212,7 +212,7 @@ def iris_detect_watched_domains(
212212
),
213213
discovered_since: str = typer.Option(
214214
None,
215-
"--discovered_since",
215+
"--discovered-since",
216216
help="ISO 8601 datetime format: default None. Filter domains by when they were discovered.",
217217
),
218218
changed_since: str = typer.Option(
@@ -256,13 +256,13 @@ def iris_detect_watched_domains(
256256
creds_file: str = typer.Option(
257257
"~/.dtapi",
258258
"-c",
259-
"--cred_file",
259+
"--credfile",
260260
help="Optional file with API username and API key, one per line.",
261261
),
262262
rate_limit: bool = typer.Option(
263263
False,
264264
"-l",
265-
"--rate_limit",
265+
"--rate-limit",
266266
help="Rate limit API calls against the API based on per minute limits.",
267267
),
268268
format: str = typer.Option(
@@ -273,7 +273,7 @@ def iris_detect_watched_domains(
273273
callback=DTCLICommand.validate_format_input,
274274
),
275275
out_file: typer.FileTextWrite = typer.Option(
276-
sys.stdout, "-o", "--out_file", help="Output file (defaults to stdout)"
276+
sys.stdout, "-o", "--out-file", help="Output file (defaults to stdout)"
277277
),
278278
no_verify_ssl: bool = typer.Option(
279279
False,
@@ -304,13 +304,13 @@ def iris_detect_manage_watchlist_domains(
304304
creds_file: str = typer.Option(
305305
"~/.dtapi",
306306
"-c",
307-
"--cred_file",
307+
"--credfile",
308308
help="Optional file with API username and API key, one per line.",
309309
),
310310
rate_limit: bool = typer.Option(
311311
False,
312312
"-l",
313-
"--rate_limit",
313+
"--rate-limit",
314314
help="Rate limit API calls against the API based on per minute limits.",
315315
),
316316
format: str = typer.Option(
@@ -321,7 +321,7 @@ def iris_detect_manage_watchlist_domains(
321321
callback=DTCLICommand.validate_format_input,
322322
),
323323
out_file: typer.FileTextWrite = typer.Option(
324-
sys.stdout, "-o", "--out_file", help="Output file (defaults to stdout)"
324+
sys.stdout, "-o", "--out-file", help="Output file (defaults to stdout)"
325325
),
326326
no_verify_ssl: bool = typer.Option(
327327
False,
@@ -354,13 +354,13 @@ def iris_detect_escalate_domains(
354354
creds_file: str = typer.Option(
355355
"~/.dtapi",
356356
"-c",
357-
"--cred_file",
357+
"--credfile",
358358
help="Optional file with API username and API key, one per line.",
359359
),
360360
rate_limit: bool = typer.Option(
361361
False,
362362
"-l",
363-
"--rate_limit",
363+
"--rate-limit",
364364
help="Rate limit API calls against the API based on per minute limits.",
365365
),
366366
format: str = typer.Option(
@@ -371,7 +371,7 @@ def iris_detect_escalate_domains(
371371
callback=DTCLICommand.validate_format_input,
372372
),
373373
out_file: typer.FileTextWrite = typer.Option(
374-
sys.stdout, "-o", "--out_file", help="Output file (defaults to stdout)"
374+
sys.stdout, "-o", "--out-file", help="Output file (defaults to stdout)"
375375
),
376376
no_verify_ssl: bool = typer.Option(
377377
False,
@@ -399,7 +399,7 @@ def iris_detect_ignored_domains(
399399
),
400400
escalation_types: str = typer.Option(
401401
None,
402-
"--escalation_types",
402+
"--escalation-types",
403403
help="List of escalation types to filter domains by. Valid values are: {'blocked', 'google_safe'}",
404404
),
405405
escalated_since: str = typer.Option(
@@ -421,7 +421,7 @@ def iris_detect_ignored_domains(
421421
),
422422
discovered_since: str = typer.Option(
423423
None,
424-
"--discovered_since",
424+
"--discovered-since",
425425
help="ISO 8601 datetime format: default None. Filter domains by when they were discovered.",
426426
),
427427
changed_since: str = typer.Option(
@@ -465,13 +465,13 @@ def iris_detect_ignored_domains(
465465
creds_file: str = typer.Option(
466466
"~/.dtapi",
467467
"-c",
468-
"--cred_file",
468+
"--credfile",
469469
help="Optional file with API username and API key, one per line.",
470470
),
471471
rate_limit: bool = typer.Option(
472472
False,
473473
"-l",
474-
"--rate_limit",
474+
"--rate-limit",
475475
help="Rate limit API calls against the API based on per minute limits.",
476476
),
477477
format: str = typer.Option(
@@ -482,7 +482,7 @@ def iris_detect_ignored_domains(
482482
callback=DTCLICommand.validate_format_input,
483483
),
484484
out_file: typer.FileTextWrite = typer.Option(
485-
sys.stdout, "-o", "--out_file", help="Output file (defaults to stdout)"
485+
sys.stdout, "-o", "--out-file", help="Output file (defaults to stdout)"
486486
),
487487
no_verify_ssl: bool = typer.Option(
488488
False,

0 commit comments

Comments
 (0)