Skip to content

Commit

Permalink
Support long form arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
remcohaszing committed Feb 17, 2024
1 parent da59af7 commit ff18f26
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 17 deletions.
18 changes: 10 additions & 8 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -85,18 +85,20 @@ As a standalone script

::

usage: wakeonlan [-h] [-i ip] [-p port] [-n interface] mac address [mac address ...]
usage: wakeonlan [-h] [-6] [-i IP] [-p PORT] [-n INTERFACE] mac address [mac address ...]

Wake one or more computers using the wake on lan protocol.

positional arguments:
mac address The mac addresses of the computers you are trying to wake.

optional arguments:
-h, --help show this help message and exit
-i ip The ip address of the host to send the magic packet to. (default 255.255.255.255)
-p port The port of the host to send the magic packet to. (default 9)
-n interface The ip address of the network adapter to route the magic packet through. (optional)
mac address The mac addresses of the computers you are trying to wake.

options:
-h, --help show this help message and exit
-6, --ipv6 To indicate if ipv6 should be used by default instead of ipv4. (default: False)
-i IP, --ip IP The ip address of the host to send the magic packet to. (default: 255.255.255.255)
-p PORT, --port PORT The port of the host to send the magic packet to. (default: 9)
-n INTERFACE, --interface INTERFACE
The ip address of the network adapter to route the magic packet through. (default: None)


************
Expand Down
18 changes: 9 additions & 9 deletions wakeonlan/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,36 +102,36 @@ def main(argv: typing.Optional[typing.List[str]] = None) -> None:
)
parser.add_argument(
'-6',
dest='use_ipv6',
'--ipv6',
action='store_true',
help='To indicate if ipv6 should be used by default instead of ipv4.',
)
parser.add_argument(
'-i',
metavar='ip',
'--ip',
default=BROADCAST_IP,
help='The ip address of the host to send the magic packet to.',
)
parser.add_argument(
'-p',
metavar='port',
'--port',
type=int,
default=DEFAULT_PORT,
help='The port of the host to send the magic packet to.',
)
parser.add_argument(
'-n',
metavar='interface',
default=None,
'--interface',
help='The ip address of the network adapter to route the magic packet through.',
)
args = parser.parse_args(argv)
print(args)
send_magic_packet(
*args.macs,
ip_address=args.i,
port=args.p,
interface=args.n,
address_family=socket.AF_INET6 if args.use_ipv6 else None,
ip_address=args.ip,
port=args.port,
interface=args.interface,
address_family=socket.AF_INET6 if args.ipv6 else None,
)


Expand Down

0 comments on commit ff18f26

Please sign in to comment.