diff --git a/docs/TODO.md b/docs/TODO.md index 68c2279..d13346c 100644 --- a/docs/TODO.md +++ b/docs/TODO.md @@ -44,7 +44,7 @@ ## Breaking changes (or potentially breaking) - [x] rewrite strings to f-strings -- [ ] CLI: put "override" and other debugging-related arguments into a separate argparse argument group +- [x] CLI: put "override" and other debugging-related arguments into a separate argparse argument group - [ ] Split getmac.py into separate files for methods, utils, etc. - [x] Refactor how global variables are handled - [ ] Remove all Python "Scripts" from the path, so they don't interfere with the commands we actually want (e.g. "ping"). Document this behavior! diff --git a/getmac/__main__.py b/getmac/__main__.py index dfad52c..8e97d5b 100644 --- a/getmac/__main__.py +++ b/getmac/__main__.py @@ -10,23 +10,31 @@ def main() -> None: parser = argparse.ArgumentParser( - "getmac", - description="Get the MAC address of system network " - "interfaces or remote hosts on the LAN", + prog="getmac", + description="Get MAC addresses of network interfaces or LAN hosts", ) parser.add_argument( "--version", action="version", version=f"getmac {getmac.__version__}" ) - parser.add_argument( - "-v", "--verbose", action="store_true", help="Enable output messages" + + group = parser.add_mutually_exclusive_group(required=False) + group.add_argument( + "-i", + "--interface", + type=str, + default=None, + help="Name of a network interface on the system", ) - parser.add_argument( - "-d", - "--debug", - action="count", - help="Enable debugging output. Add characters to " - "increase verbosity of output, e.g. '-dd'.", + group.add_argument( + "-4", "--ip", type=str, default=None, help="IPv4 address of a remote host" + ) + group.add_argument( + "-6", "--ip6", type=str, default=None, help="IPv6 address of a remote host" + ) + group.add_argument( + "-n", "--hostname", type=str, default=None, help="Hostname of a remote host" ) + parser.add_argument( "-N", "--no-net", @@ -35,14 +43,29 @@ def main() -> None: dest="NO_NET", help="Do not use arping or send a UDP packet to refresh the ARP table", ) - parser.add_argument( + + tshooting = parser.add_argument_group("troubleshooting") + tshooting.add_argument( + "-v", + "--verbose", + action="store_true", + help="Enable logging messages (by default, only the MAC is printed to the terminal)", + ) + tshooting.add_argument( + "-d", + "--debug", + action="count", + help="Enable debugging output. Add 'd' characters to " + "increase verbosity of output, e.g. '-dd' to set DEBUG=2.", + ) + tshooting.add_argument( "--override-port", type=int, metavar="PORT", help="Override the default UDP port used to refresh the ARP table " "if network requests are enabled and arping is unavailable", ) - parser.add_argument( + tshooting.add_argument( "--override-platform", type=str, default=None, @@ -51,7 +74,7 @@ def main() -> None: "(e.g. 'linux', 'windows', 'freebsd', etc.'). " "Any values returned by platform.system() are valid.", ) - parser.add_argument( + tshooting.add_argument( "--force-method", type=str, default=None, @@ -61,24 +84,6 @@ def main() -> None: "compatibility, and Method.test() will NOT be checked!", ) - group = parser.add_mutually_exclusive_group(required=False) - group.add_argument( - "-i", - "--interface", - type=str, - default=None, - help="Name of a network interface on the system", - ) - group.add_argument( - "-4", "--ip", type=str, default=None, help="IPv4 address of a remote host" - ) - group.add_argument( - "-6", "--ip6", type=str, default=None, help="IPv6 address of a remote host" - ) - group.add_argument( - "-n", "--hostname", type=str, default=None, help="Hostname of a remote host" - ) - args = parser.parse_args() if args.debug or args.verbose: