Skip to content

Commit

Permalink
feat(cli): basic usage of docopts
Browse files Browse the repository at this point in the history
For now we just show it works within our generator.
Next step is to actually generate docopts grammar.
  • Loading branch information
Byron committed Apr 9, 2015
1 parent 6db7332 commit 390354b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
4 changes: 4 additions & 0 deletions etc/api/type-cli.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,7 @@ make:
cargo:
build_version: "0.0.1"
keywords: [cli]
dependencies:
- docopt = "*"
- docopt_macros = "*"
- rustc-serialize = "*"
27 changes: 27 additions & 0 deletions src/mako/cli/main.rs.mako
Original file line number Diff line number Diff line change
@@ -1,3 +1,30 @@
#![feature(plugin)]
#![plugin(docopt_macros)]

extern crate docopt;
extern crate rustc_serialize;

docopt!(Args derive Debug, "
Usage: rtrace [options] (<OUTPUT-FILE>|-)
rtrace --help

Options:
--width <X> The width of the output image [default: 1024]
--height <Y> The height of the output image [default: 1024]
--samples-per-pixel <SAMPLES> Amount of samples per pixel. 4 means 16 over-samples [default: 1]
--num-cores <NUM_CORES> Amount of cores to do the rendering on [default: 1]
If this is not set, you may also use the RTRACEMAXPROCS
environment variable, e.g. RTRACEMAXPROCS=4.
The commandline always overrides environment variables.

<OUTPUT-FILE>|- Either a file with .tga extension, or - to write file to stdout
"
, flag_samples_per_pixel: u16
, flag_height: u16
, flag_width: u16
, flag_num_cores: usize);

fn main() {
let _: Args = Args::docopt().decode().unwrap_or_else(|e| e.exit());
println!("Hello, ${id} !");
}

0 comments on commit 390354b

Please sign in to comment.