summaryrefslogtreecommitdiff
path: root/src/vtcol.rs
diff options
context:
space:
mode:
authorPhilipp Gesang <phg@phi-gamma.net>2021-11-24 20:45:52 +0100
committerPhilipp Gesang <phg@phi-gamma.net>2021-11-24 20:45:52 +0100
commitfab3a5aea7107688b957ffc2502ed1539c7fad70 (patch)
treeba82f8e0f5c911ee1ad1ac1183a09dbd3b0663eb /src/vtcol.rs
parentfc6cec72aead59c1d45044e8945c5b8119eab823 (diff)
downloadvtcol-fab3a5aea7107688b957ffc2502ed1539c7fad70.tar.gz
add base64 output for ‘get’
Diffstat (limited to 'src/vtcol.rs')
-rw-r--r--src/vtcol.rs24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/vtcol.rs b/src/vtcol.rs
index e3ab5f2..0a198e6 100644
--- a/src/vtcol.rs
+++ b/src/vtcol.rs
@@ -30,7 +30,7 @@ enum Job
/** Switch to color scheme. */
Set(Scheme),
/** Get currently active scheme. */
- Get,
+ Get(bool),
/** Toggle between two schemes. */
Toggle(Scheme, Scheme),
/** Fade from current scheme to another. */
@@ -79,7 +79,16 @@ impl<'a> Job
),
)
.subcommand(
- SubCommand::with_name("get").about("get current color scheme"),
+ SubCommand::with_name("get")
+ .about("get current color scheme")
+ .arg(
+ Arg::with_name("base64")
+ .short("b")
+ .long("base64")
+ .help("base64 encoded binary output")
+ .required(false)
+ .takes_value(false),
+ ),
)
.subcommand(
SubCommand::with_name("toggle")
@@ -185,7 +194,7 @@ impl<'a> Job
};
Ok(Self::Set(scheme))
},
- ("get", _) => Ok(Self::Get),
+ ("get", Some(subm)) => Ok(Self::Get(subm.is_present("base64"))),
("toggle", Some(subm)) => {
match (subm.value_of("one"), subm.value_of("two")) {
(Some(one), Some(two)) => {
@@ -287,7 +296,7 @@ impl<'a> Job
Self::Dump(scm) => Self::dump(scm)?,
Self::List => Self::list_schemes(),
Self::Set(scm) => Self::set_scheme(scm)?,
- Self::Get => Self::get_scheme()?,
+ Self::Get(b64) => Self::get_scheme(b64)?,
Self::Toggle(one, two) => Self::toggle_scheme(one, two)?,
Self::Fade(from, to, ms, hz, clear) =>
Self::fade(from, to, ms, hz, clear)?,
@@ -309,11 +318,16 @@ impl<'a> Job
Ok(())
}
- fn get_scheme() -> Result<()>
+ fn get_scheme(b64: bool) -> Result<()>
{
let fd = Console::current()?;
vrb!("console fd: {}", fd);
+ if b64 {
+ let pal = fd.current_palette()?;
+ println!("{}", pal.base64());
+ }
+
let scm = fd.current_scheme()?;
vrb!("active scheme:");