FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cecli/cecli/format_settings.py at main · cecli-dev/cecli · GitHub
cecli-dev
cecli
Repository navigation
Code
Issues
11
(11)
Pull requests
8
(8)
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cecli
/
cecli
/
format_settings.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
38 lines (34 loc) · 1.47 KB
Breadcrumbs
cecli
/
cecli
/
format_settings.py
Copy path
File metadata and controls
38 lines (34 loc) · 1.47 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
35
36
37
38
import
os
def
scrub_sensitive_info
(
args
,
text
):
# Replace sensitive information with last 4 characters
if
text
and
args
.
openai_api_key
:
last_4
=
args
.
openai_api_key
[
-
4
:]
text
=
text
.
replace
(
args
.
openai_api_key
,
f"...
{
last_4
}
"
)
if
text
and
args
.
anthropic_api_key
:
last_4
=
args
.
anthropic_api_key
[
-
4
:]
text
=
text
.
replace
(
args
.
anthropic_api_key
,
f"...
{
last_4
}
"
)
return
text
def
format_settings
(
parser
,
args
):
show
=
scrub_sensitive_info
(
args
,
parser
.
format_values
())
# clean up the headings for consistency w/ new lines
heading_env
=
"Environment Variables:"
heading_defaults
=
"Defaults:"
if
heading_env
in
show
:
show
=
show
.
replace
(
heading_env
,
"
\n
"
+
heading_env
)
show
=
show
.
replace
(
heading_defaults
,
"
\n
"
+
heading_defaults
)
show
+=
"
\n
"
show
+=
"Option settings:
\n
"
for
arg
,
val
in
sorted
(
vars
(
args
).
items
()):
if
val
:
val
=
scrub_sensitive_info
(
args
,
str
(
val
))
show
+=
f" -
{
arg
}
:
{
val
}
\n
"
# noqa: E221
# Add environment variables that start with CECLI_
show
+=
"
\n
Environment variables:
\n
"
for
env_var
,
env_val
in
sorted
(
os
.
environ
.
items
()):
if
env_var
.
startswith
(
"CECLI_"
):
# Scrub sensitive env vars if needed
if
"API_KEY"
in
env_var
and
env_val
:
last_4
=
env_val
[
-
4
:]
if
len
(
env_val
)
>=
4
else
env_val
env_val
=
f"...
{
last_4
}
"
show
+=
f" -
{
env_var
}
:
{
env_val
}
\n
"
return
show
Back
|
FazBrowse Home
|
New Git URL