diff options
author | Jovansonlee Cesar <ivanceras@gmail.com> | 2018-02-19 02:37:27 +0800 |
---|---|---|
committer | Jovansonlee Cesar <ivanceras@gmail.com> | 2018-02-19 02:37:27 +0800 |
commit | 8d3faa0e4934b1e5e553c43fb4606122bfc775f0 (patch) | |
tree | 88fc7d18d6716963b90428a6101ee52fec4666d9 | |
parent | 65d57a9b139c226228a747cc7bfc9bb8dcc43871 (diff) | |
parent | a11a1d4e9ad71e5756a5d6c79221bfe7fdfe160d (diff) |
various tests
-rw-r--r-- | README.md | 20 | ||||
-rw-r--r-- | spec.md | 10 | ||||
-rw-r--r-- | svgbob/Cargo.lock | 67 | ||||
-rw-r--r-- | svgbob/Cargo.toml | 3 | ||||
-rw-r--r-- | svgbob/src/lib.rs | 9 | ||||
-rw-r--r-- | svgbob/tests/bench.rs | 1 | ||||
-rw-r--r-- | svgbob/tests/issues.rs | 4 | ||||
-rw-r--r-- | svgbob/tests/mem_consumption.rs | 116 | ||||
-rw-r--r-- | svgbob_cli/Cargo.lock | 101 | ||||
-rw-r--r-- | svgbob_cli/Cargo.toml | 2 | ||||
-rw-r--r-- | svgbob_cli/examples/svgbob | 1 | ||||
-rw-r--r-- | svgbob_cli/src/main.rs | 44 |
12 files changed, 289 insertions, 89 deletions
@@ -35,24 +35,38 @@ $ svgbob -o long.svg < examples/long.bob $ svgbob examples/long.bob > long.svg ``` +You can pipe string from the output of other program: +```console +echo -e "+--+\n| |\n+--+" | svgbob +``` +You can also pass an inline string: +```console +svgbob -s -- "+--+\n| |\n+--+" +``` + This is also documented in the output of `svgbob --help`: ```console $ svgbob --help -svgbob 0.1.2 +svgbob 0.2.1 SvgBobRus is an ascii to svg converter USAGE: - svgbob [OPTIONS] [input] + svgbob [FLAGS] [OPTIONS] [input] [SUBCOMMAND] FLAGS: -h, --help Prints help information + -s parse an inline string -V, --version Prints version information OPTIONS: -o, --output <output> where to write svg output [default: STDOUT] ARGS: - <input> svgbob text file to parse [default: STDIN] + <input> svgbob text file or inline string to parse [default: STDIN] + +SUBCOMMANDS: + build Batch convert files to svg. + help Prints this message or the help of the given subcommand(s) ``` @@ -60,6 +60,16 @@ Default values: |`--` |`<line x1="0" y1="8" x2="16" y2="8"/>` |<svg width="16" height="16"><line x1="0" y1="8" x2="16" y2="8"/></svg> |`----`|`<line x1="0" y1="8" x2="32" y2="8"/>` |<svg width="32" height="16"><line x1="0" y1="8" x2="32" y2="8"/></svg> +```bob ++---------------+-------- +|"-" | - | ++-------+-------+-------- +|"--" | -- | ++-------+-------+-------- +|"----" | ---- | ++-------+-------+--------- +``` + **Example 3:** Next to an alphanumeric character |text |svg |rendered diff --git a/svgbob/Cargo.lock b/svgbob/Cargo.lock index ee7441a..6cd455a 100644 --- a/svgbob/Cargo.lock +++ b/svgbob/Cargo.lock @@ -1,4 +1,14 @@ [[package]] +name = "cc" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "cfg-if" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "difference" version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -8,16 +18,32 @@ name = "handlebars" version = "0.21.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", + "log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)", "pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quick-error 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] +name = "libc" +version = "0.2.36" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] name = "log" -version = "0.3.8" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] +name = "log" +version = "0.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "pest" @@ -26,7 +52,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "pom" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -39,7 +65,7 @@ dependencies = [ [[package]] name = "quick-error" -version = "1.2.0" +version = "1.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -49,33 +75,48 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "svg" -version = "0.5.6" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "svgbob" -version = "0.2.1" +version = "0.2.3" dependencies = [ "handlebars 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)", - "pom 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", + "pom 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", "pretty_assertions 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", - "svg 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "svg 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)", + "sys-info 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] +name = "sys-info" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "unicode-width" version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] +"checksum cc 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "deaf9ec656256bb25b404c51ef50097207b9cbb29c933d31f92cae5a8a0ffee0" +"checksum cfg-if 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d4c819a1287eb618df47cc647173c5c4c66ba19d888a6e50d605672aed3140de" "checksum difference 1.0.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b3304d19798a8e067e48d8e69b2c37f0b5e9b4e462504ad9e27e9f3fce02bba8" "checksum handlebars 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)" = "937e9d49d65ffb5f70e95710a6c8539addf40200275ad8b6cdba0f0a59d5814d" -"checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b" +"checksum libc 0.2.36 (registry+https://github.com/rust-lang/crates.io-index)" = "1e5d97d6708edaa407429faa671b942dc0f2727222fb6b6539bf1db936e4b121" +"checksum log 0.3.9 (registry+https://github.com/rust-lang/crates.io-index)" = "e19e8d5c34a3e0e2223db8e060f9e8264aeeb5c5fc64a4ee9965c062211c024b" +"checksum log 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)" = "89f010e843f2b1a31dbd316b3b8d443758bc634bed37aabade59c686d644e0a2" "checksum pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0a6dda33d67c26f0aac90d324ab2eb7239c819fc7b2552fe9faa4fe88441edc8" -"checksum pom 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8678ba1b3c8f2afef0fbfeb21c1c9dd44165d11923ecaec02925122fabdf4e69" +"checksum pom 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60f6ce597ecdcc9a098e7fddacb1065093a3d66446fa16c675e7e71d1b5c28e6" "checksum pretty_assertions 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1d510007841e87c7a6d829a36f7f0acb72aef12e38cc89073fe39810c1d976ac" -"checksum quick-error 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c36987d4978eb1be2e422b1e0423a557923a5c3e7e6f31d5699e9aafaefa469" +"checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" -"checksum svg 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6569d8ee08322afcc9f3eb19a9af4ebbb5a2502a4048cb32f741020a02b0d668" +"checksum svg 0.5.10 (registry+https://github.com/rust-lang/crates.io-index)" = "5ce4450d6982b758228fa5407db2fc27cefccb013c170ade23c03ec3a643bb72" +"checksum sys-info 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "617f594d3869801871433390254b4a79f2a18176d7f4ad5784fa990bc8c12986" "checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" diff --git a/svgbob/Cargo.toml b/svgbob/Cargo.toml index ab221ae..104f6e8 100644 --- a/svgbob/Cargo.toml +++ b/svgbob/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "svgbob" -version = "0.2.1" +version = "0.2.3" authors = ["Jovansonlee Cesar <ivanceras@gmail.com>"] description = "Transform your ascii diagrams into happy little SVG" repository = "https://github.com/ivanceras/svgbobrus" @@ -18,3 +18,4 @@ pom = "1.0.1" [dev-dependencies] handlebars = "0.21" pretty_assertions = "0.2" +sys-info = "0.5.1" diff --git a/svgbob/src/lib.rs b/svgbob/src/lib.rs index b8f6e74..8eedb6b 100644 --- a/svgbob/src/lib.rs +++ b/svgbob/src/lib.rs @@ -573,6 +573,7 @@ fn exclude_escaped_text(line: &str) -> (String, Vec<(usize, String)>) { buffer.push_str(&" ".repeat(end+1 - start)); index = end + 1; } + buffer.push_str(&line[index..line.len()]); } else{ buffer.push_str(line); @@ -1067,8 +1068,8 @@ fn test_escaped_string(){ let mut index = 0; if let Ok(output) = output3{ for (start, end) in output{ - println!("matches: {}", &input3[start...end]); - matches.push(input3[start...end].to_string()); + println!("matches: {}", &input3[start..=end]); + matches.push(input3[start..=end].to_string()); let slice = &input3[index..start]; recons.push_str(slice); recons.push_str(&" ".repeat(end+1-start)); @@ -1098,8 +1099,8 @@ fn test_escaped_multiline_string(){ let mut index = 0; if let Ok(output) = output3{ for (start, end) in output{ - println!("matches: {}", &input3[start...end]); - matches.push(input3[start...end].to_string()); + println!("matches: {}", &input3[start..=end]); + matches.push(input3[start..=end].to_string()); let slice = &input3[index..start]; recons.push_str(slice); recons.push_str(&" ".repeat(end+1-start)); diff --git a/svgbob/tests/bench.rs b/svgbob/tests/bench.rs index 8ad40eb..e6fa454 100644 --- a/svgbob/tests/bench.rs +++ b/svgbob/tests/bench.rs @@ -8,6 +8,7 @@ use test::Bencher; mod tests { #![feature(test)] extern crate test; + extern crate sys_info; use super::*; #[bench] diff --git a/svgbob/tests/issues.rs b/svgbob/tests/issues.rs index 529242f..e617b93 100644 --- a/svgbob/tests/issues.rs +++ b/svgbob/tests/issues.rs @@ -1,6 +1,10 @@ extern crate svgbob; +<<<<<<< HEAD #[test] +======= +//#[test] +>>>>>>> a11a1d4e9ad71e5756a5d6c79221bfe7fdfe160d fn issue15(){ use svgbob::{Grid,Settings}; let input = "+--+\n| |\n+--+"; diff --git a/svgbob/tests/mem_consumption.rs b/svgbob/tests/mem_consumption.rs new file mode 100644 index 0000000..92599e5 --- /dev/null +++ b/svgbob/tests/mem_consumption.rs @@ -0,0 +1,116 @@ +#![feature(libc)] +extern crate sys_info; +extern crate svgbob; +extern crate libc; +extern {fn je_stats_print (write_cb: extern fn (*const libc::c_void, *const libc::c_char), cbopaque: *const libc::c_void, opts: *const libc::c_char);} +extern fn write_cb (_: *const libc::c_void, message: *const libc::c_char) { + print! ("{}", String::from_utf8_lossy (unsafe {std::ffi::CStr::from_ptr (message as *const i8) .to_bytes()}));} + +#[test] +fn show_mem_consumption(){ + +let arg = r#" ++------+ +-----+ +-----+ +-----+ +| | | | | | | | +| Foo +-->| Bar +---+ Baz |<--+ Moo | +| | | | | | | | ++------+ +-----+ +--+--+ +-----+ + ^ | + | V +.-------------+-----------------------. +| Hello here and there and everywhere | +'-------------------------------------' + ____________ + .--------------. \ \ + / a == b \ \ \ __________ + ( && ) ) process ) \ \ + \ 'string' ne '' / / / / process / + '--------------' /___________/ /_________/ + __________________ + \_________________\ + \ \ + . another process . + /_________________/ + /_________________/ + User code ^ ^ OS code + \ / + \ .--' + \ / + User code <--- Mode ----> OS code + / \ + .--' \___ + / \ + v v + User code OS code + .---. .---. .---. .---. .---. .---. + OS API '---' '---' '---' '---' '---' '---' + | | | | | | + v v | v | v + .------------. | .-----------. | .-----. + | Filesystem | | | Scheduler | | | MMU | + '------------' | '-----------' | '-----' + | | | | + v | | v + .----. | | .---------. + | IO |<----' | | Network | + '----' | '---------' + | | | + v v v + .---------------------------------------. + | HAL | + '---------------------------------------' + + ____[] + | ___ | + || || device + ||___|| loads + | ooo |----------------------------------------------------------. + | ooo | | | | + | ooo | | | | + '-----' | | | + | | | + v v v + .-------------------. .---------------------------. .-------------------. + | Loadable module C | | Loadable module A | | Loadable module B | + '-------------------' |---------------------------| | (instrumented) | + | | .-----. | '-------------------' + '------------+-------->| A.o | | | + calls | '-----' | | + | .------------------. | | + | / A.instrumented.o /<---+-------------' + | '------------------' | calls + '---------------------------' + .--------------. + \ \ + '--------------' + .--> Base::Class::Derived_A + / + .----> Base::Class::Derived_B + Something -------. / \ + \ / .---> Base::Class::Derived + Something::else \ / \ + \ \ / '--> Base::Class::Derived + \ \ / + \ \ .-----------> Base::Class::Derived_C + \ \ / + '------ Base::Class + / \ \ \ + ' \ \ \ + | \ \ \ + . \ \ '--- The::Latest + /| \ \ \ + With::Some::fantasy ' \ \ '---- The::Latest::Greatest + /| \ \ + More::Stuff ' \ '- I::Am::Running::Out::Of::Ideas + /| \ + More::Stuff ' \ + / '--- Last::One + More::Stuff V +"#; + + println!("before: {:?}", sys_info::mem_info().unwrap()); + unsafe{je_stats_print(write_cb, std::ptr::null(), std::ptr::null())}; + self::svgbob::to_svg(arg); + println!("after: {:?}", sys_info::mem_info().unwrap()); + unsafe{je_stats_print(write_cb, std::ptr::null(), std::ptr::null())}; +} diff --git a/svgbob_cli/Cargo.lock b/svgbob_cli/Cargo.lock index 1a12cdf..d50f125 100644 --- a/svgbob_cli/Cargo.lock +++ b/svgbob_cli/Cargo.lock @@ -1,13 +1,3 @@ -[root] -name = "svgbob_cli" -version = "0.2.1" -dependencies = [ - "clap 2.26.0 (registry+https://github.com/rust-lang/crates.io-index)", - "handlebars 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)", - "svg 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", - "svgbob 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "ansi_term" version = "0.9.0" @@ -15,11 +5,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "atty" -version = "0.2.2" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)", "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -30,16 +21,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "clap" -version = "2.26.0" +version = "2.27.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", - "atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", + "atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", "bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)", "strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)", - "term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "textwrap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", "vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -51,7 +40,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ "log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)", "pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)", - "quick-error 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)", + "quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)", ] @@ -66,7 +55,7 @@ dependencies = [ [[package]] name = "libc" -version = "0.2.30" +version = "0.2.33" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] @@ -81,15 +70,28 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "pom" -version = "1.0.1" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "quick-error" -version = "1.2.0" +version = "1.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "redox_syscall" +version = "0.1.31" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "redox_termios" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "rustc-serialize" version = "0.3.24" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -101,42 +103,46 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "svg" -version = "0.5.6" +version = "0.5.7" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] name = "svgbob" -version = "0.2.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "pom 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)", - "svg 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)", + "pom 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "svg 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "term_size" -version = "0.3.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +name = "svgbob_cli" +version = "0.2.3" dependencies = [ - "kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)", - "winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)", + "clap 2.27.1 (registry+https://github.com/rust-lang/crates.io-index)", + "handlebars 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)", + "svg 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)", + "svgbob 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "textwrap" -version = "0.7.0" +name = "termion" +version = "1.5.1" source = "registry+https://github.com/rust-lang/crates.io-index" dependencies = [ - "term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", - "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", + "libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)", + "redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] -name = "unicode-segmentation" -version = "1.2.0" +name = "textwrap" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)", +] [[package]] name = "unicode-width" @@ -160,23 +166,24 @@ source = "registry+https://github.com/rust-lang/crates.io-index" [metadata] "checksum ansi_term 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "23ac7c30002a5accbf7e8987d0632fa6de155b7c3d39d0067317a391e00a2ef6" -"checksum atty 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "d912da0db7fa85514874458ca3651fe2cddace8d0b0505571dbdcd41ab490159" +"checksum atty 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "21e50800ec991574876040fff8ee46b136a53e985286fbe6a3bdfe6421b78860" "checksum bitflags 0.9.1 (registry+https://github.com/rust-lang/crates.io-index)" = "4efd02e230a02e18f92fc2735f44597385ed02ad8f831e7c1c1156ee5e1ab3a5" -"checksum clap 2.26.0 (registry+https://github.com/rust-lang/crates.io-index)" = "2267a8fdd4dce6956ba6649e130f62fb279026e5e84b92aa939ac8f85ce3f9f0" +"checksum clap 2.27.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1b8c532887f1a292d17de05ae858a8fe50a301e196f9ef0ddb7ccd0d1d00f180" "checksum handlebars 0.21.1 (registry+https://github.com/rust-lang/crates.io-index)" = "937e9d49d65ffb5f70e95710a6c8539addf40200275ad8b6cdba0f0a59d5814d" "checksum kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)" = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -"checksum libc 0.2.30 (registry+https://github.com/rust-lang/crates.io-index)" = "2370ca07ec338939e356443dac2296f581453c35fe1e3a3ed06023c49435f915" +"checksum libc 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "5ba3df4dcb460b9dfbd070d41c94c19209620c191b0340b929ce748a2bcd42d2" "checksum log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)" = "880f77541efa6e5cc74e76910c9884d9859683118839d6a1dc3b11e63512565b" "checksum pest 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)" = "0a6dda33d67c26f0aac90d324ab2eb7239c819fc7b2552fe9faa4fe88441edc8" -"checksum pom 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "8678ba1b3c8f2afef0fbfeb21c1c9dd44165d11923ecaec02925122fabdf4e69" -"checksum quick-error 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "3c36987d4978eb1be2e422b1e0423a557923a5c3e7e6f31d5699e9aafaefa469" +"checksum pom 1.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "60f6ce597ecdcc9a098e7fddacb1065093a3d66446fa16c675e7e71d1b5c28e6" +"checksum quick-error 1.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "eda5fe9b71976e62bc81b781206aaa076401769b2143379d3eb2118388babac4" +"checksum redox_syscall 0.1.31 (registry+https://github.com/rust-lang/crates.io-index)" = "8dde11f18c108289bef24469638a04dce49da56084f2d50618b226e47eb04509" +"checksum redox_termios 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7e891cfe48e9100a70a3b6eb652fef28920c117d366339687bd5576160db0f76" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694" -"checksum svg 0.5.6 (registry+https://github.com/rust-lang/crates.io-index)" = "6569d8ee08322afcc9f3eb19a9af4ebbb5a2502a4048cb32f741020a02b0d668" -"checksum svgbob 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "5a3023339a2ef0a1a35c2ad1bbded4169dedeb2c4ce65081bac7838dd8ec6f4b" -"checksum term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b6b55df3198cc93372e85dd2ed817f0e38ce8cc0f22eb32391bfad9c4bf209" -"checksum textwrap 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)" = "f728584ea33b0ad19318e20557cb0a39097751dbb07171419673502f848c7af6" -"checksum unicode-segmentation 1.2.0 (registry+https://github.com/rust-lang/crates.io-index)" = "a8083c594e02b8ae1654ae26f0ade5158b119bd88ad0e8227a5d8fcd72407946" +"checksum svg 0.5.7 (registry+https://github.com/rust-lang/crates.io-index)" = "68f5d080e5fab99e42fc678d16b436842aa30d33d40a869e7a561f24f04a76a9" +"checksum svgbob 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "c77ad459197be280d55916ed67d84d4c8d9954c543009c4829b3a693247fcd1a" +"checksum termion 1.5.1 (registry+https://github.com/rust-lang/crates.io-index)" = "689a3bdfaab439fd92bc87df5c4c78417d3cbe537487274e9b0b2dce76e92096" +"checksum textwrap 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)" = "c0b59b6b4b44d867f1370ef1bd91bfb262bf07bf0ae65c202ea2fbc16153b693" "checksum unicode-width 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)" = "bf3a113775714a22dcb774d8ea3655c53a32debae63a063acc00a91cc586245f" "checksum vec_map 0.8.0 (registry+https://github.com/rust-lang/crates.io-index)" = "887b5b631c2ad01628bbbaa7dd4c869f80d3186688f8d0b6f58774fbe324988c" "checksum winapi 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" diff --git a/svgbob_cli/Cargo.toml b/svgbob_cli/Cargo.toml index bbbf773..4a7c9c0 100644 --- a/svgbob_cli/Cargo.toml +++ b/svgbob_cli/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "svgbob_cli" -version = "0.2.1" +version = "0.2.3" authors = ["Jovansonlee Cesar <ivanceras@gmail.com>"] description = "Transform your ascii diagrams into happy little SVG" repository = "https://github.com/ivanceras/svgbobrus" diff --git a/svgbob_cli/examples/svgbob b/svgbob_cli/examples/svgbob deleted file mode 100644 index ce01362..0000000 --- a/svgbob_cli/examples/svgbob +++ /dev/null @@ -1 +0,0 @@ -hello diff --git a/svgbob_cli/src/main.rs b/svgbob_cli/src/main.rs index 18ed74c..efcd155 100644 --- a/svgbob_cli/src/main.rs +++ b/svgbob_cli/src/main.rs @@ -21,7 +21,8 @@ fn main() { let args = App::new("svgbob") .version(crate_version!()) .about("SvgBobRus is an ascii to svg converter") - .arg(Arg::with_name("input").index(1).help("svgbob text file to parse [default: STDIN]")) + .arg(Arg::with_name("inline").short("s").help("parse an inline string")) + .arg(Arg::with_name("input").index(1).help("svgbob text file or inline string to parse [default: STDIN]")) .arg(Arg::with_name("output") .short("o") .long("output") @@ -51,26 +52,31 @@ fn main() { } let mut bob = String::new(); - if let Some(file) = args.value_of("input") { - match File::open(file) { - Ok(mut f) => { - f.read_to_string(&mut bob).unwrap(); - } - Err(e) => { - use std::io::Write; - use std::process::exit; - - writeln!(&mut std::io::stderr(), - "Failed to open input file {}: {}", - file, - e) - .unwrap(); - exit(1); + + if args.is_present("inline") { + bob = args.value_of("input").unwrap().replace("\\n","\n").to_string(); + } else { + if let Some(file) = args.value_of("input") { + match File::open(file) { + Ok(mut f) => { + f.read_to_string(&mut bob).unwrap(); + } + Err(e) => { + use std::io::Write; + use std::process::exit; + + writeln!(&mut std::io::stderr(), + "Failed to open input file {}: {}", + file, + e) + .unwrap(); + exit(1); + } } + } else { + use std::io; + io::stdin().read_to_string(&mut bob).unwrap(); } - } else { - use std::io; - io::stdin().read_to_string(&mut bob).unwrap(); } let g = Grid::from_str(&*bob, &Settings::compact()); |