Skip to content

Commit 57c7ae9

Browse files
committed
Moving to clap v3
1 parent 823b392 commit 57c7ae9

File tree

3 files changed

+79
-53
lines changed

3 files changed

+79
-53
lines changed

Cargo.lock

Lines changed: 49 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ exclude = ["/.semaphore", "/data", "/release.sh", ".*"]
1515
[dependencies]
1616

1717
# CLI & utilities
18-
clap = { version = "2.33", default-features = false, features = [ "suggestions", "color"] }
18+
clap = { version = "3", default-features = false, features = ["std", "suggestions", "color"] }
1919
ansi_term = "0.12"
2020
rand = "0.8"
2121
ctrlc = "3.2"

src/args.rs

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const CLI_VERSION: &str = env!("CARGO_PKG_VERSION");
2424
const EXAMPLES_HELP: &str = "EXAMPLES:
2525
2626
# Launch a default scan with on the first working interface
27-
arp- scann
27+
arp-scan
2828
2929
# List network interfaces
3030
arp-scan -l
@@ -41,120 +41,120 @@ const EXAMPLES_HELP: &str = "EXAMPLES:
4141
* This function groups together all exposed CLI arguments to the end-users
4242
* with clap. Other CLI details (version, ...) should be grouped there as well.
4343
*/
44-
pub fn build_args<'a, 'b>() -> App<'a, 'b> {
44+
pub fn build_args<'a>() -> App<'a> {
4545

4646
App::new("arp-scan")
4747
.version(CLI_VERSION)
4848
.about("A minimalistic ARP scan tool written in Rust")
4949
.arg(
50-
Arg::with_name("profile").short("p").long("profile")
50+
Arg::new("profile").short('p').long("profile")
5151
.takes_value(true).value_name("PROFILE_NAME")
5252
.help("Scan profile")
5353
)
5454
.arg(
55-
Arg::with_name("interface").short("i").long("interface")
55+
Arg::new("interface").short('i').long("interface")
5656
.takes_value(true).value_name("INTERFACE_NAME")
5757
.help("Network interface")
5858
)
5959
.arg(
60-
Arg::with_name("network").short("n").long("network")
60+
Arg::new("network").short('n').long("network")
6161
.takes_value(true).value_name("NETWORK_RANGE")
6262
.help("Network range to scan")
6363
)
6464
.arg(
65-
Arg::with_name("file").short("f").long("file")
65+
Arg::new("file").short('f').long("file")
6666
.takes_value(true).value_name("FILE_PATH")
6767
.conflicts_with("network")
6868
.help("Read IPv4 addresses from a file")
6969
)
7070
.arg(
71-
Arg::with_name("timeout").short("t").long("timeout")
71+
Arg::new("timeout").short('t').long("timeout")
7272
.takes_value(true).value_name("TIMEOUT_DURATION")
7373
.help("ARP response timeout")
7474
)
7575
.arg(
76-
Arg::with_name("source_ip").short("S").long("source-ip")
76+
Arg::new("source_ip").short('S').long("source-ip")
7777
.takes_value(true).value_name("SOURCE_IPV4")
7878
.help("Source IPv4 address for requests")
7979
)
8080
.arg(
81-
Arg::with_name("destination_mac").short("M").long("dest-mac")
81+
Arg::new("destination_mac").short('M').long("dest-mac")
8282
.takes_value(true).value_name("DESTINATION_MAC")
8383
.help("Destination MAC address for requests")
8484
)
8585
.arg(
86-
Arg::with_name("source_mac").long("source-mac")
86+
Arg::new("source_mac").long("source-mac")
8787
.takes_value(true).value_name("SOURCE_MAC")
8888
.help("Source MAC address for requests")
8989
)
9090
.arg(
91-
Arg::with_name("numeric").long("numeric")
91+
Arg::new("numeric").long("numeric")
9292
.takes_value(false)
9393
.help("Numeric mode, no hostname resolution")
9494
)
9595
.arg(
96-
Arg::with_name("vlan").short("Q").long("vlan")
96+
Arg::new("vlan").short('Q').long("vlan")
9797
.takes_value(true).value_name("VLAN_ID")
9898
.help("Send using 802.1Q with VLAN ID")
9999
)
100100
.arg(
101-
Arg::with_name("retry_count").short("r").long("retry")
101+
Arg::new("retry_count").short('r').long("retry")
102102
.takes_value(true).value_name("RETRY_COUNT")
103103
.help("Host retry attempt count")
104104
)
105105
.arg(
106-
Arg::with_name("random").short("R").long("random")
106+
Arg::new("random").short('R').long("random")
107107
.takes_value(false)
108108
.help("Randomize the target list")
109109
)
110110
.arg(
111-
Arg::with_name("interval").short("I").long("interval")
111+
Arg::new("interval").short('I').long("interval")
112112
.takes_value(true).value_name("INTERVAL_DURATION")
113113
.help("Milliseconds between ARP requests")
114114
)
115115
.arg(
116-
Arg::with_name("bandwidth").short("B").long("bandwidth")
116+
Arg::new("bandwidth").short('B').long("bandwidth")
117117
.takes_value(true).value_name("BITS")
118118
.conflicts_with("interval")
119119
.help("Limit scan bandwidth (bits/second)")
120120
)
121121
.arg(
122-
Arg::with_name("oui-file").long("oui-file")
122+
Arg::new("oui-file").long("oui-file")
123123
.takes_value(true).value_name("FILE_PATH")
124124
.help("Path to custom IEEE OUI CSV file")
125125
)
126126
.arg(
127-
Arg::with_name("list").short("l").long("list")
127+
Arg::new("list").short('l').long("list")
128128
.takes_value(false)
129129
.help("List network interfaces")
130130
)
131131
.arg(
132-
Arg::with_name("output").short("o").long("output")
132+
Arg::new("output").short('o').long("output")
133133
.takes_value(true).value_name("FORMAT")
134134
.help("Define output format")
135135
)
136136
.arg(
137-
Arg::with_name("hw_type").long("hw-type")
137+
Arg::new("hw_type").long("hw-type")
138138
.takes_value(true).value_name("HW_TYPE")
139139
.help("Custom ARP hardware field")
140140
)
141141
.arg(
142-
Arg::with_name("hw_addr").long("hw-addr")
142+
Arg::new("hw_addr").long("hw-addr")
143143
.takes_value(true).value_name("ADDRESS_LEN")
144144
.help("Custom ARP hardware address length")
145145
)
146146
.arg(
147-
Arg::with_name("proto_type").long("proto-type")
147+
Arg::new("proto_type").long("proto-type")
148148
.takes_value(true).value_name("PROTO_TYPE")
149149
.help("Custom ARP proto type")
150150
)
151151
.arg(
152-
Arg::with_name("proto_addr").long("proto-addr")
152+
Arg::new("proto_addr").long("proto-addr")
153153
.takes_value(true).value_name("ADDRESS_LEN")
154154
.help("Custom ARP proto address length")
155155
)
156156
.arg(
157-
Arg::with_name("arp_operation").long("arp-op")
157+
Arg::new("arp_operation").long("arp-op")
158158
.takes_value(true).value_name("OPERATION_ID")
159159
.help("Custom ARP operation ID")
160160
)
@@ -425,7 +425,7 @@ impl ScanOptions {
425425
None => "/usr/share/arp-scan/ieee-oui.csv".to_string()
426426
};
427427

428-
let hw_type = match matches.value_of("hw-type") {
428+
let hw_type = match matches.value_of("hw_type") {
429429
Some(hw_type_text) => {
430430

431431
match hw_type_text.parse::<u16>() {
@@ -439,7 +439,7 @@ impl ScanOptions {
439439
None => None
440440
};
441441

442-
let hw_addr = match matches.value_of("hw-addr") {
442+
let hw_addr = match matches.value_of("hw_addr") {
443443
Some(hw_addr_text) => {
444444

445445
match hw_addr_text.parse::<u8>() {
@@ -453,7 +453,7 @@ impl ScanOptions {
453453
None => None
454454
};
455455

456-
let proto_type = match matches.value_of("proto-type") {
456+
let proto_type = match matches.value_of("proto_type") {
457457
Some(proto_type_text) => {
458458

459459
match proto_type_text.parse::<u16>() {
@@ -467,7 +467,7 @@ impl ScanOptions {
467467
None => None
468468
};
469469

470-
let proto_addr = match matches.value_of("proto-addr") {
470+
let proto_addr = match matches.value_of("proto_addr") {
471471
Some(proto_addr_text) => {
472472

473473
match proto_addr_text.parse::<u8>() {
@@ -481,7 +481,7 @@ impl ScanOptions {
481481
None => None
482482
};
483483

484-
let arp_operation = match matches.value_of("arp-op") {
484+
let arp_operation = match matches.value_of("arp_operation") {
485485
Some(arp_op_text) => {
486486

487487
match arp_op_text.parse::<u16>() {

0 commit comments

Comments
 (0)