feat(wallpaper_changer): add CUstomArgPArser to raise ValueError on false argument
This commit is contained in:
1 parent
b8a30ad3dd
commit
27df6ce7f8
1 file changed
+8
-4
@@ -12,9 +12,12 @@ from wallpaper_changer.logging_utils import get_logger
|
||||
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
class CustomArgumentParser(ArgumentParser):
|
||||
def error(self, message):
|
||||
raise ValueError(message)
|
||||
|
||||
def build_parser() -> ArgumentParser:
|
||||
parser = ArgumentParser(
|
||||
parser = CustomArgumentParser(
|
||||
prog="wallpaperchanger",
|
||||
description="Wallpaper changer and encrypted wallpaper vault manager",
|
||||
)
|
||||
@@ -181,5 +184,6 @@ def parse_args(argv: Sequence[str] | None = None) -> Namespace:
|
||||
comments=True,
|
||||
)
|
||||
config_args = parser.parse_args(config_tokens)
|
||||
|
||||
return parser.parse_args(command_line, namespace=config_args)
|
||||
if not config_args:
|
||||
raise ValueError("No arguments found in config file")
|
||||
return parser.parse_args(command_line, namespace=config_args)
|
||||
Reference in new issue
Block a user