Skip to content

Commit

Permalink
Reorganize CLI help for clarity
Browse files Browse the repository at this point in the history
  • Loading branch information
GhostofGoes committed Oct 13, 2023
1 parent 0836fd3 commit 90440f4
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 33 deletions.
2 changes: 1 addition & 1 deletion docs/TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -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!
Expand Down
69 changes: 37 additions & 32 deletions getmac/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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,
Expand All @@ -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,
Expand All @@ -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:
Expand Down

0 comments on commit 90440f4

Please sign in to comment.