-
-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathargs.py
More file actions
34 lines (26 loc) · 803 Bytes
/
args.py
File metadata and controls
34 lines (26 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import json
import logging
from pathlib import PosixPath
import click
from codecov_cli import __version__
from codecov_cli.opentelemetry import set_cli_tags
logger = logging.getLogger("codecovcli")
def get_cli_args(ctx: click.Context):
args = ctx.obj["cli_args"]
args["command"] = str(ctx.command.name)
args["version"] = f"cli-{__version__}"
args.update(ctx.params)
if "token" in args:
del args["token"]
filtered_args = {}
for k in args.keys():
try:
if isinstance(args[k], PosixPath):
filtered_args[k] = str(args[k])
else:
json.dumps(args[k])
filtered_args[k] = args[k]
except Exception:
continue
set_cli_tags(filtered_args, ctx)
return filtered_args