Add --show-sensitive CLI option

This commit is contained in:
Matthias 2024-03-20 07:06:24 +01:00
parent 6b7935f1ae
commit 81d1a662a2
4 changed files with 15 additions and 4 deletions

View File

@ -62,7 +62,7 @@ ARGS_TEST_PAIRLIST = ["user_data_dir", "verbosity", "config", "quote_currencies"
ARGS_CREATE_USERDIR = ["user_data_dir", "reset"]
ARGS_BUILD_CONFIG = ["config"]
ARGS_SHOW_CONFIG = ["user_data_dir", "config"]
ARGS_SHOW_CONFIG = ["user_data_dir", "config", "show_sensitive"]
ARGS_BUILD_STRATEGY = ["user_data_dir", "strategy", "template"]

View File

@ -276,8 +276,10 @@ def start_show_config(args: Dict[str, Any]) -> None:
# TODO: Sanitize from sensitive info before printing
print("Your combined configuration is:")
config_sanitized = sanitize_config(config['original_config'])
config_sanitized = sanitize_config(
config['original_config'],
show_sensitive=args.get('show_sensitive', False)
)
from rich import print_json
print_json(data=config_sanitized)

View File

@ -716,4 +716,10 @@ AVAILABLE_CLI_OPTIONS = {
help='Specify startup candles to be checked (`199`, `499`, `999`, `1999`).',
nargs='+',
),
"show_sensitive": Arg(
'--show-sensitive',
help='Show secrets in the output.',
action='store_true',
default=False,
),
}

View File

@ -3,12 +3,15 @@
from freqtrade.constants import Config
def sanitize_config(config: Config) -> Config:
def sanitize_config(config: Config, *, show_sensitive: bool = False) -> Config:
"""
Remove sensitive information from the config.
:param config: Configuration
:param show_sensitive: Show sensitive information
:return: Configuration
"""
if show_sensitive:
return config
keys_to_remove = [
"exchange.key",
"exchange.secret",