Skip to content

Commit 7438005

Browse files
committed
design: start adding args to subcommands and global
Signed-off-by: Paul Osborne <[email protected]>
1 parent a87bd58 commit 7438005

File tree

1 file changed

+61
-7
lines changed

1 file changed

+61
-7
lines changed

src/main.rs

Lines changed: 61 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,22 +6,76 @@ fn main() {
66
let gpio_cmd_matches = App::new("GPIO Utils")
77
.version(env!("CARGO_PKG_VERSION"))
88
.about("Read, Write, and Configure GPIOs")
9+
10+
// Global options
11+
.arg(Arg::with_name("config")
12+
.help("additional configuration to use")
13+
.takes_value(true)
14+
.short("c")
15+
.long("config")
16+
.multiple(true)
17+
.required(false))
18+
19+
// gpio read
920
.subcommand(SubCommand::with_name("read")
10-
.about("Read the value of a GPIO Input"))
21+
.about("Read the value of a GPIO Input")
22+
.arg(Arg::with_name("pin")
23+
.help("The pin name (or number)")
24+
.index(1)
25+
.required(true)))
26+
27+
// gpio poll
1128
.subcommand(SubCommand::with_name("poll")
12-
.about("Wait for an event to happen on an GPIO Input"))
29+
.about("Wait for an event to happen on an GPIO Input")
30+
.arg(Arg::with_name("pin")
31+
.help("The pin name (or number)")
32+
.index(1)
33+
.required(true)))
34+
35+
// gpio write
1336
.subcommand(SubCommand::with_name("write")
14-
.about("Write the value of a GPIO Output"))
37+
.about("Write the value of a GPIO Output")
38+
.arg(Arg::with_name("pin")
39+
.help("The pin name (or number)")
40+
.index(1)
41+
.required(true)))
42+
43+
// gpio export
1544
.subcommand(SubCommand::with_name("export")
16-
.about("Export a given GPIO"))
45+
.about("Export a given GPIO")
46+
.arg(Arg::with_name("pin")
47+
.help("The pin name (or number)")
48+
.index(1)
49+
.required(true)))
50+
51+
// gpio export-all
1752
.subcommand(SubCommand::with_name("export-all")
1853
.about("Export all configured GPIOs"))
54+
55+
// gpio unexport
1956
.subcommand(SubCommand::with_name("unexport")
20-
.about("Unexport a given GPIO"))
57+
.about("Unexport a given GPIO")
58+
.arg(Arg::with_name("pin")
59+
.help("The pin name (or number)")
60+
.index(1)
61+
.required(true)))
62+
63+
// gpio unexport-all
2164
.subcommand(SubCommand::with_name("unexport-all")
22-
.about("Unexport all configured, exported GPIOs"))
65+
.about("Unexport all configured, exported GPIOs")
66+
.arg(Arg::with_name("pin")
67+
.help("The pin name (or number)")
68+
.index(1)
69+
.required(true)))
70+
71+
// gpio status
2372
.subcommand(SubCommand::with_name("status")
24-
.about("Output status of all configured GPIOs"))
73+
.about("Output status of all configured GPIOs")
74+
.arg(Arg::with_name("pin")
75+
.help("The pin name (or number)")
76+
.index(1)
77+
.required(false)))
78+
2579
.get_matches();
2680

2781
match gpio_cmd_matches.subcommand() {

0 commit comments

Comments
 (0)