Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unrecognized arguments error when no device is found. #213 #214

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 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,16 +68,19 @@ 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()
if "--help" not in args and "-h" not in args and not mouse:
print("E: No supported device found.")
sys.exit(1)
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

cli_parser = argparse.ArgumentParser(prog="rivalcfg", epilog=_EPILOG)
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