From b4aadcde1ccf9021f7f47b3d8453faa333850e76 Mon Sep 17 00:00:00 2001 From: Philipp Gesang Date: Wed, 24 Nov 2021 21:11:53 +0100 Subject: =?UTF-8?q?add=20base64=20input=20to=20=E2=80=98dump=E2=80=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/vtcol.rs | 30 +++++++++++++++++++++++------- 1 file 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)); -- cgit v1.2.3