diff --git a/Cargo.lock b/Cargo.lock index cfc6522..1f7b422 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -497,7 +497,7 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" [[package]] name = "sql-hummus" -version = "0.1.4" +version = "0.1.5" dependencies = [ "anyhow", "camino", diff --git a/Cargo.toml b/Cargo.toml index 9e64bf1..9424a2d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,7 @@ keywords = ["database", "sqlite"] license-file = "LICENSE.md" readme = "README.md" repository = "https://github.com/ReactorScram/sql-hummus" -version = "0.1.4" +version = "0.1.5" [dependencies] anyhow = { version = "1.0.103", features = ["backtrace"] } diff --git a/src/cli.rs b/src/cli.rs index a47b250..7ce7976 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -34,7 +34,7 @@ pub(crate) enum Command { }, /// Quick paste to the default log file. Uses `wl-paste` - Paste, + Paste { annotation: Option }, /// Quick push to the default log file Push { content: Option }, diff --git a/src/main.rs b/src/main.rs index c33801b..863141e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -110,13 +110,15 @@ fn inner_main() -> Result { match cli.cmd { Command::Kv { cmd, path } => run_kv_command(path, cmd), Command::Log { cmd, path } => run_log_command(path, cmd), - Command::Paste => { - let output = std::process::Command::new("wl-paste") + Command::Paste { annotation } => { + let clipboard = std::process::Command::new("wl-paste") .output() .context("wl-paste failed")?; - let content = str::from_utf8(output.stdout.as_slice())?; + let clipboard = str::from_utf8(clipboard.stdout.as_slice())?; + let content = json!({ "annotation": annotation, "clipboard": clipboard }); + let (log, path) = Log::open_default().context("Log::open_default() failed")?; - let index = log.push(content)?; + let index = log.push(serde_json::to_string(&content)?)?; let output = json!({ "content": content, "index": index, "path": path }); println!("{}", serde_json::to_string(&output)?); Ok(true)