Skip to content

Commit ff18f26

Browse files
committed
Support long form arguments
1 parent da59af7 commit ff18f26

File tree

2 files changed

+19
-17
lines changed

2 files changed

+19
-17
lines changed

README.rst

+10-8
Original file line numberDiff line numberDiff line change
@@ -85,18 +85,20 @@ As a standalone script
8585

8686
::
8787

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

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

9292
positional arguments:
93-
mac address The mac addresses of the computers you are trying to wake.
94-
95-
optional arguments:
96-
-h, --help show this help message and exit
97-
-i ip The ip address of the host to send the magic packet to. (default 255.255.255.255)
98-
-p port The port of the host to send the magic packet to. (default 9)
99-
-n interface The ip address of the network adapter to route the magic packet through. (optional)
93+
mac address The mac addresses of the computers you are trying to wake.
94+
95+
options:
96+
-h, --help show this help message and exit
97+
-6, --ipv6 To indicate if ipv6 should be used by default instead of ipv4. (default: False)
98+
-i IP, --ip IP The ip address of the host to send the magic packet to. (default: 255.255.255.255)
99+
-p PORT, --port PORT The port of the host to send the magic packet to. (default: 9)
100+
-n INTERFACE, --interface INTERFACE
101+
The ip address of the network adapter to route the magic packet through. (default: None)
100102

101103

102104
************

wakeonlan/__init__.py

+9-9
Original file line numberDiff line numberDiff line change
@@ -102,36 +102,36 @@ def main(argv: typing.Optional[typing.List[str]] = None) -> None:
102102
)
103103
parser.add_argument(
104104
'-6',
105-
dest='use_ipv6',
105+
'--ipv6',
106106
action='store_true',
107107
help='To indicate if ipv6 should be used by default instead of ipv4.',
108108
)
109109
parser.add_argument(
110110
'-i',
111-
metavar='ip',
111+
'--ip',
112112
default=BROADCAST_IP,
113113
help='The ip address of the host to send the magic packet to.',
114114
)
115115
parser.add_argument(
116116
'-p',
117-
metavar='port',
117+
'--port',
118118
type=int,
119119
default=DEFAULT_PORT,
120120
help='The port of the host to send the magic packet to.',
121121
)
122122
parser.add_argument(
123123
'-n',
124-
metavar='interface',
125-
default=None,
124+
'--interface',
126125
help='The ip address of the network adapter to route the magic packet through.',
127126
)
128127
args = parser.parse_args(argv)
128+
print(args)
129129
send_magic_packet(
130130
*args.macs,
131-
ip_address=args.i,
132-
port=args.p,
133-
interface=args.n,
134-
address_family=socket.AF_INET6 if args.use_ipv6 else None,
131+
ip_address=args.ip,
132+
port=args.port,
133+
interface=args.interface,
134+
address_family=socket.AF_INET6 if args.ipv6 else None,
135135
)
136136

137137

0 commit comments

Comments
 (0)