Skip to content

Commit

Permalink
Merge branch 'LennardKittner-Unrecognized-arguments-error-when-no-dev…
Browse files Browse the repository at this point in the history
…ice-is-found.-#213'
  • Loading branch information
flozz committed Jul 4, 2023
2 parents 10304d5 + 8896f1c commit 591a9ac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
18 changes: 11 additions & 7 deletions rivalcfg/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def _render_battery_level(level=None, is_charging=None):

def main(args=sys.argv[1:]):
# Display a message when no argument given
if len(sys.argv) == 1:
if not args:
print("USAGE:\n rivalcfg --help")
sys.exit(1)

Expand All @@ -68,18 +68,22 @@ def main(args=sys.argv[1:]):
# Try to open a mouse
mouse = None
if (
"--print-debug" not in sys.argv
and "--list" not in sys.argv
and "--version" not in sys.argv
and "--update-udev" not in sys.argv
and "--print-udev" not in sys.argv
"--print-debug" not in args
and "--list" not in args
and "--version" not in args
and "--update-udev" not in args
and "--print-udev" not in args
):
try:
mouse = get_first_mouse()
except IOError as error:
if "--help" not in sys.argv and "-h" not in sys.argv:
if "--help" not in args and "-h" not in args:
raise error

if not mouse and "--help" not in args and "-h" not in args:
print("E: No supported device found.")
sys.exit(1)

cli_parser = argparse.ArgumentParser(prog="rivalcfg", epilog=_EPILOG)
cli.add_main_cli(cli_parser)

Expand Down
4 changes: 2 additions & 2 deletions rivalcfg/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def __call__(self, parser, namespace, value, option_string=None):


class PrintDebugAction(argparse.Action):
"""Prints debug informations and exit."""
"""Prints debug information and exit."""

def __call__(self, parser, namespace, value, option_string=None):
print(debug.get_debug_info())
Expand Down Expand Up @@ -126,7 +126,7 @@ def add_main_cli(cli_parser):

cli_parser.add_argument(
"--print-debug",
help="Prints debug informations and exit",
help="Prints debug information and exit",
nargs=0,
action=PrintDebugAction,
)
Expand Down

0 comments on commit 591a9ac

Please sign in to comment.