blob: 25cbc34dd6f303a556559895d3490fb0a590a880 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
//! Command line program to convert a roadmap from a named YAML input
//! file to SVG, written to the standard output.
//!
//! Example
//!
//! ~~~sh
//! roadmap2svg foo.yaml > foo.svg
//! ~~~
//!
//! The command line program mostly exists just to make it easier to
//! test the library crate. It is expected that serious use of the
//! crate will be as a library.
use roadmap::Roadmap;
use structopt::StructOpt;
use std::path::PathBuf;
use std::fs::File;
use std::io::Read;
const LABEL_WIDTH: usize = 30;
#[derive(Debug, StructOpt)]
#[structopt(name = "roadmap2dot", about = "Create a dot graph of a roadmap in YAML")]
struct Opt {
// The input filename.
#[structopt(parse(from_os_str))]
filename: PathBuf,
}
fn main() -> Result<(), Box<dyn std::error::Error>> {
let opt = Opt::from_args();
let mut text = String::new();
let mut f = File::open(opt.filename)?;
f.read_to_string(&mut text)?;
let mut r = Roadmap::from_yaml(&text)?;
r.set_missing_statuses();
println!("{}", r.as_dot(LABEL_WIDTH).unwrap());
Ok(())
}
|