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