make as cli arg
This commit is contained in:
parent
158209fdd1
commit
ad8d30b83f
5 changed files with 19 additions and 19 deletions
|
|
@ -271,6 +271,6 @@ def main() -> List[Subscription]:
|
||||||
transaction_log_file_path=args.transaction_log,
|
transaction_log_file_path=args.transaction_log,
|
||||||
)
|
)
|
||||||
|
|
||||||
output_summary(subscriptions, config=config)
|
output_summary(subscriptions, suppress_colors=args.suppress_colors)
|
||||||
|
|
||||||
return subscriptions
|
return subscriptions
|
||||||
|
|
|
||||||
|
|
@ -36,14 +36,14 @@ def _color_int(value: int, suppress_colors: bool = False) -> str:
|
||||||
return _no_color(str_int, suppress_colors)
|
return _no_color(str_int, suppress_colors)
|
||||||
|
|
||||||
|
|
||||||
def output_summary(subscriptions: List[Subscription], config: ConfigFile) -> None:
|
def output_summary(subscriptions: List[Subscription], suppress_colors: bool) -> None:
|
||||||
"""
|
"""
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
subscriptions
|
subscriptions
|
||||||
Processed subscriptions
|
Processed subscriptions
|
||||||
config
|
suppress_colors
|
||||||
ConfigFile instance
|
Whether to have color or not
|
||||||
|
|
||||||
Returns
|
Returns
|
||||||
-------
|
-------
|
||||||
|
|
@ -57,8 +57,6 @@ def output_summary(subscriptions: List[Subscription], config: ConfigFile) -> Non
|
||||||
|
|
||||||
summary: List[str] = []
|
summary: List[str] = []
|
||||||
|
|
||||||
suppress_colors = config.config_options.suppress_colors
|
|
||||||
|
|
||||||
# Initialize totals to 0
|
# Initialize totals to 0
|
||||||
total_subs: int = len(subscriptions)
|
total_subs: int = len(subscriptions)
|
||||||
total_subs_str = f"Total: {total_subs}"
|
total_subs_str = f"Total: {total_subs}"
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,10 @@ class MainArguments:
|
||||||
short="-m",
|
short="-m",
|
||||||
long="--match",
|
long="--match",
|
||||||
)
|
)
|
||||||
|
SUPPRESS_COLORS = CLIArgument(
|
||||||
|
short="-nc",
|
||||||
|
long="--suppress-colors"
|
||||||
|
)
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
def all(cls) -> List[CLIArgument]:
|
def all(cls) -> List[CLIArgument]:
|
||||||
|
|
@ -59,6 +63,7 @@ class MainArguments:
|
||||||
cls.TRANSACTION_LOG,
|
cls.TRANSACTION_LOG,
|
||||||
cls.SUPPRESS_TRANSACTION_LOG,
|
cls.SUPPRESS_TRANSACTION_LOG,
|
||||||
cls.MATCH,
|
cls.MATCH,
|
||||||
|
cls.SUPPRESS_COLORS,
|
||||||
]
|
]
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|
@ -129,6 +134,13 @@ def _add_shared_arguments(arg_parser: argparse.ArgumentParser, suppress_defaults
|
||||||
help="do not output transaction logs to console or file",
|
help="do not output transaction logs to console or file",
|
||||||
default=argparse.SUPPRESS if suppress_defaults else False,
|
default=argparse.SUPPRESS if suppress_defaults else False,
|
||||||
)
|
)
|
||||||
|
arg_parser.add_argument(
|
||||||
|
MainArguments.SUPPRESS_COLORS.short,
|
||||||
|
MainArguments.SUPPRESS_COLORS.long,
|
||||||
|
action="store_true",
|
||||||
|
help="do not use colors in ytdl-sub output",
|
||||||
|
default=argparse.SUPPRESS if suppress_defaults else False
|
||||||
|
)
|
||||||
arg_parser.add_argument(
|
arg_parser.add_argument(
|
||||||
MainArguments.MATCH.short,
|
MainArguments.MATCH.short,
|
||||||
MainArguments.MATCH.long,
|
MainArguments.MATCH.long,
|
||||||
|
|
|
||||||
|
|
@ -108,7 +108,6 @@ class ConfigOptions(StrictDictValidator):
|
||||||
"ffprobe_path",
|
"ffprobe_path",
|
||||||
"file_name_max_bytes",
|
"file_name_max_bytes",
|
||||||
"experimental",
|
"experimental",
|
||||||
"suppress_colors",
|
|
||||||
}
|
}
|
||||||
|
|
||||||
def __init__(self, name: str, value: Any):
|
def __init__(self, name: str, value: Any):
|
||||||
|
|
@ -143,9 +142,6 @@ class ConfigOptions(StrictDictValidator):
|
||||||
self._file_name_max_bytes = self._validate_key(
|
self._file_name_max_bytes = self._validate_key(
|
||||||
key="file_name_max_bytes", validator=IntValidator, default=MAX_FILE_NAME_BYTES
|
key="file_name_max_bytes", validator=IntValidator, default=MAX_FILE_NAME_BYTES
|
||||||
)
|
)
|
||||||
self._suppress_colors = self._validate_key_if_present(
|
|
||||||
key="suppress_colors", validator=BoolValidator, default=False
|
|
||||||
)
|
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def working_directory(self) -> str:
|
def working_directory(self) -> str:
|
||||||
|
|
@ -239,12 +235,6 @@ class ConfigOptions(StrictDictValidator):
|
||||||
"""
|
"""
|
||||||
return self._ffprobe_path.value
|
return self._ffprobe_path.value
|
||||||
|
|
||||||
@property
|
|
||||||
def suppress_colors(self) -> bool:
|
|
||||||
"""
|
|
||||||
Flag to disable colors in the output summary
|
|
||||||
"""
|
|
||||||
return self._suppress_colors.value
|
|
||||||
|
|
||||||
class ConfigValidator(StrictDictValidator):
|
class ConfigValidator(StrictDictValidator):
|
||||||
_optional_keys = {"configuration", "presets"}
|
_optional_keys = {"configuration", "presets"}
|
||||||
|
|
|
||||||
|
|
@ -36,7 +36,7 @@ def test_output_summary_no_errors():
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
output_summary(subscriptions=mock_subscriptions)
|
output_summary(subscriptions=mock_subscriptions, suppress_colors=False)
|
||||||
|
|
||||||
|
|
||||||
def test_output_summary_one_error():
|
def test_output_summary_one_error():
|
||||||
|
|
@ -50,7 +50,7 @@ def test_output_summary_one_error():
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
output_summary(subscriptions=mock_subscriptions)
|
output_summary(subscriptions=mock_subscriptions, suppress_colors=False)
|
||||||
|
|
||||||
|
|
||||||
def test_output_summary_multiple_errors():
|
def test_output_summary_multiple_errors():
|
||||||
|
|
@ -64,4 +64,4 @@ def test_output_summary_multiple_errors():
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
|
|
||||||
output_summary(subscriptions=mock_subscriptions)
|
output_summary(subscriptions=mock_subscriptions, suppress_colors=True)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue