Skip to content

Commit a87bd58

Browse files
committed
design: stub out basic subcommands using clap
The details aren't fleshed out yet but this should put a little more meat on the bones for review. Signed-off-by: Paul Osborne <[email protected]>
1 parent b715edb commit a87bd58

File tree

4 files changed

+132
-1
lines changed

4 files changed

+132
-1
lines changed

.travis.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
language: rust
2+
sudo: false
3+
4+
rust:
5+
- 1.2.0
6+
- 1.3.0
7+
- 1.4.0
8+
- 1.5.0
9+
- 1.6.0
10+
- stable
11+
- beta
12+
- nightly
13+
14+
script:
15+
- cargo test
16+
- cargo doc

Cargo.lock

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

Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ version = "0.1.0"
44
authors = ["Paul Osborne <[email protected]>"]
55

66
[dependencies]
7+
sysfs_gpio = "0.4.0"
8+
clap = "2.2"

src/main.rs

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
extern crate clap;
2+
3+
use clap::{Arg, App, SubCommand};
4+
15
fn main() {
2-
println!("Hello, world!");
6+
let gpio_cmd_matches = App::new("GPIO Utils")
7+
.version(env!("CARGO_PKG_VERSION"))
8+
.about("Read, Write, and Configure GPIOs")
9+
.subcommand(SubCommand::with_name("read")
10+
.about("Read the value of a GPIO Input"))
11+
.subcommand(SubCommand::with_name("poll")
12+
.about("Wait for an event to happen on an GPIO Input"))
13+
.subcommand(SubCommand::with_name("write")
14+
.about("Write the value of a GPIO Output"))
15+
.subcommand(SubCommand::with_name("export")
16+
.about("Export a given GPIO"))
17+
.subcommand(SubCommand::with_name("export-all")
18+
.about("Export all configured GPIOs"))
19+
.subcommand(SubCommand::with_name("unexport")
20+
.about("Unexport a given GPIO"))
21+
.subcommand(SubCommand::with_name("unexport-all")
22+
.about("Unexport all configured, exported GPIOs"))
23+
.subcommand(SubCommand::with_name("status")
24+
.about("Output status of all configured GPIOs"))
25+
.get_matches();
26+
27+
match gpio_cmd_matches.subcommand() {
28+
("read", Some(m)) => {},
29+
("poll", Some(m)) => {},
30+
("write", Some(m)) => {},
31+
("export", Some(m)) => {},
32+
("export-all", Some(m)) => {},
33+
("unexport", Some(m)) => {},
34+
("unexport-all", Some(m)) => {},
35+
("status", Some(m)) => {},
36+
_ => {}
37+
}
338
}

0 commit comments

Comments
 (0)