summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2021-11-24 21:11:53 +0100
committerPhilipp Gesang <phg@phi-gamma.net>2021-11-24 21:11:53 +0100
commitb4aadcde1ccf9021f7f47b3d8453faa333850e76 (patch)
treea38caf155c81072dc09a5442b887d3eef957689f
parentc5305231d900cca8189a9995284258a841042f50 (diff)
downloadvtcol-b4aadcde1ccf9021f7f47b3d8453faa333850e76.tar.gz
add base64 input to ‘dump’
-rw-r--r--src/vtcol.rs30
1 files changed, 23 insertions, 7 deletions
diff --git a/src/vtcol.rs b/src/vtcol.rs
index 8161241..256d137 100644
--- a/src/vtcol.rs
+++ b/src/vtcol.rs
@@ -48,13 +48,24 @@ impl<'a> Job
.author(clap::crate_authors!())
.about(clap::crate_description!())
.subcommand(
- SubCommand::with_name("dump").about("dump a color scheme").arg(
- Arg::with_name("scheme")
- .help("name of the scheme")
- .required(true)
- .value_name("NAME")
- .takes_value(true),
- ),
+ SubCommand::with_name("dump")
+ .about("dump a color scheme")
+ .arg(
+ Arg::with_name("scheme")
+ .help("name of the scheme")
+ .required(false)
+ .value_name("NAME")
+ .takes_value(true),
+ )
+ .arg(
+ Arg::with_name("base64")
+ .short("b")
+ .long("base64")
+ .value_name("DATA")
+ .help("base64 encoded binary input")
+ .required(false)
+ .takes_value(true),
+ ),
)
.subcommand(
SubCommand::with_name("list").about("list available schemes"),
@@ -175,6 +186,11 @@ impl<'a> Job
match matches.subcommand() {
("dump", Some(subm)) => {
+ if let Some(b64) = subm.value_of("base64") {
+ let scheme =
+ Palette::from_base64(&b64).map(Scheme::from)?;
+ return Ok(Self::Dump(scheme));
+ }
if let Some(name) = subm.value_of("scheme") {
let scm = Scheme::from(name);
return Ok(Self::Dump(scm));