Skip to content

Commit 390354b

Browse files
committed
feat(cli): basic usage of docopts
For now we just show it works within our generator. Next step is to actually generate docopts grammar.
1 parent 6db7332 commit 390354b

2 files changed

Lines changed: 31 additions & 0 deletions

File tree

etc/api/type-cli.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,7 @@ make:
1919
cargo:
2020
build_version: "0.0.1"
2121
keywords: [cli]
22+
dependencies:
23+
- docopt = "*"
24+
- docopt_macros = "*"
25+
- rustc-serialize = "*"

src/mako/cli/main.rs.mako

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,30 @@
1+
#![feature(plugin)]
2+
#![plugin(docopt_macros)]
3+
4+
extern crate docopt;
5+
extern crate rustc_serialize;
6+
7+
docopt!(Args derive Debug, "
8+
Usage: rtrace [options] (<OUTPUT-FILE>|-)
9+
rtrace --help
10+
11+
Options:
12+
--width <X> The width of the output image [default: 1024]
13+
--height <Y> The height of the output image [default: 1024]
14+
--samples-per-pixel <SAMPLES> Amount of samples per pixel. 4 means 16 over-samples [default: 1]
15+
--num-cores <NUM_CORES> Amount of cores to do the rendering on [default: 1]
16+
If this is not set, you may also use the RTRACEMAXPROCS
17+
environment variable, e.g. RTRACEMAXPROCS=4.
18+
The commandline always overrides environment variables.
19+
20+
<OUTPUT-FILE>|- Either a file with .tga extension, or - to write file to stdout
21+
"
22+
, flag_samples_per_pixel: u16
23+
, flag_height: u16
24+
, flag_width: u16
25+
, flag_num_cores: usize);
26+
127
fn main() {
28+
let _: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit());
229
println!("Hello, ${id} !");
330
}

0 commit comments

Comments
 (0)