summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg42.2a@gmail.com>2015-01-25 13:35:38 +0100
committerPhilipp Gesang <phg42.2a@gmail.com>2015-01-25 13:35:38 +0100
commited6ce958d5f3d5aa495d4314288b995fb7bb358c (patch)
tree2780fefa142b9f373ff1f1bf3e32fc18c1e7d996
parent04f3bc7902f0eba88213ef418cfdfb7f325ec297 (diff)
downloadvtcol-ed6ce958d5f3d5aa495d4314288b995fb7bb358c.tar.gz
vtcol.rs: add option to list available color schemes
-rw-r--r--vtcol.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/vtcol.rs b/vtcol.rs
index acf8db7..f734525 100644
--- a/vtcol.rs
+++ b/vtcol.rs
@@ -6,6 +6,8 @@ extern crate getopts;
#[derive(Show)]
enum Scheme { Default, SolarizedDark, SolarizedLight }
+extern { fn exit (code : libc::c_int) -> !; }
+
/* struct Job -- Runtime parameters.
*/
#[derive(Show)]
@@ -24,6 +26,7 @@ impl Job {
let this = argv[0].clone();
let opts = &[
getopts::optopt("s", "scheme", "predefined color scheme", "NAME"),
+ getopts::optflag("l", "list", "list available color schemes"),
getopts::optflag("h", "help", "print this message")
];
let matches = match getopts::getopts(argv.tail(), opts)
@@ -31,6 +34,10 @@ impl Job {
Ok(m) => m,
Err(f) => panic!(f.to_string())
};
+ if matches.opt_present("l") {
+ Job::schemes();
+ unsafe { exit(0) };
+ };
let scheme = match matches.opt_str("s") {
None => {
Job::usage(&this, opts);
@@ -61,6 +68,15 @@ impl Job {
print!("{}", getopts::usage(brief.as_slice(), opts));
}
+ fn
+ schemes ()
+ {
+ println!("Available color schemes:");
+ println!(" · solarized_dark");
+ println!(" · solarized_light");
+ println!(" · default");
+ }
+
} /* [impl Job] */
/* Rust appears to come with two wrappers for ``ioctl(2)``, but neither can be utilized for our