Repository: dathere/qsv (language: rust)

Issue:
put commands that require a UI behind a feature, so qsv can be more easily deployed in headless environments
As the `clipboard` and `prompt` commands have dependencies on libraries (like `rfd`, `wayland` & `arboard`) that don't necessarily exists in headless environments (VMs, docker images, qsv.dathere.com, 100.dathere.com, etc.)


Discussion / hints:

Fix patch:
diff --git a/Cargo.toml b/Cargo.toml
index 1728be70a..ef1088c4b 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -69,7 +69,7 @@ panic    = "abort"
 
 [dependencies]
 ahash = "0.8"
-arboard = { version = "3.4.1", default-features = false }
+arboard = { version = "3.4.1", default-features = false, optional = true }
 atoi_simd = "0.16"
 base62 = { version = "2.0", optional = true }
 bytemuck = { version = "1.19", features = [
@@ -347,7 +347,7 @@ distrib_features = [
     "python",
     "to",
 ]
-all_features = ["distrib_features", "self_update"]
+all_features = ["distrib_features", "self_update", "ui"]
 apply = [
     "base62",
     "censor",
@@ -363,6 +363,7 @@ apply = [
     "titlecase",
     "whatlang",
 ]
+clipboard = ["arboard"]
 fetch = [
     "cached",
     "console",
@@ -391,6 +392,7 @@ to = ["csvs_convert"]
 lens = ["csvlens"]
 lite = []
 datapusher_plus = ["self_update"]
+ui = ["clipboard", "prompt", "lens"]
 feature_capable = []
 nightly = [
     "crc32fast/nightly",
diff --git a/src/cmd/mod.rs b/src/cmd/mod.rs
index 87af5ff8d..31980c19c 100644
--- a/src/cmd/mod.rs
+++ b/src/cmd/mod.rs
@@ -6,7 +6,7 @@ pub mod applydp;
 pub mod behead;
 #[cfg(any(feature = "feature_capable", feature = "lite"))]
 pub mod cat;
-#[cfg(any(feature = "feature_capable", feature = "lite"))]
+#[cfg(feature = "clipboard")]
 pub mod clipboard;
 pub mod count;
 pub mod datefmt;
diff --git a/src/main.rs b/src/main.rs
index 9688f722d..1bf15bc41 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -93,9 +93,15 @@ fn main() -> QsvExitCode {
 
     enabled_commands.push_str(
         "    behead      Drop header from CSV file
-    cat         Concatenate by row or column
-    clipboard   Provide input from clipboard or output to clipboard
-    count       Count records
+    cat         Concatenate by row or column\n",
+    );
+
+    #[cfg(all(feature = "clipboard", feature = "feature_capable"))]
+    enabled_commands
+        .push_str("    clipboard   Provide input from clipboard or output to clipboard\n");
+
+    enabled_commands.push_str(
+        "    count       Count records
     datefmt     Format date/datetime strings
     dedup       Remove redundant rows
     describegpt Infer extended metadata using a LLM
@@ -329,6 +335,7 @@ enum Command {
     Apply,
     Behead,
     Cat,
+    #[cfg(all(feature = "clipboard", feature = "feature_capable"))]
     Clipboard,
     Count,
     Datefmt,
@@ -422,6 +429,7 @@ impl Command {
             #[cfg(all(feature = "apply", feature = "feature_capable"))]
             Command::Apply => cmd::apply::run(argv),
             Command::Cat => cmd::cat::run(argv),
+            #[cfg(all(feature = "clipboard", feature = "feature_capable"))]
             Command::Clipboard => cmd::clipboard::run(argv),
             Command::Count => cmd::count::run(argv),
             Command::Datefmt => cmd::datefmt::run(argv),
diff --git a/src/mainlite.rs b/src/mainlite.rs
index 50682e467..37c573965 100644
--- a/src/mainlite.rs
+++ b/src/mainlite.rs
@@ -21,7 +21,6 @@ static GLOBAL: jemallocator::Jemalloc = jemallocator::Jemalloc;
 static COMMAND_LIST: &str = r#"
     behead      Drop header from CSV file
     cat         Concatenate by row or column
-    clipboard   Provide input from clipboard or output to clipboard
     count       Count records
     datefmt     Format date/datetime columns
     dedup       Remove redundant rows
@@ -146,7 +145,7 @@ fn main() -> QsvExitCode {
         None => {
             werr!(
                 "qsvlite is a suite of CSV command line utilities.\n\nPlease choose one of the \
-                 following commands:\n{COMMAND_LIST}\n\n{SPONSOR_MESSAGE}",
+                 following 49 commands:\n{COMMAND_LIST}\n\n{SPONSOR_MESSAGE}",
             );
 
             // if no command is specified, auto-check for updates 10% of the time
@@ -225,7 +224,6 @@ fn main() -> QsvExitCode {
 enum Command {
     Behead,
     Cat,
-    Clipboard,
     Count,
     Datefmt,
     Dedup,
@@ -292,7 +290,6 @@ impl Command {
         match self {
             Command::Behead => cmd::behead::run(argv),
             Command::Cat => cmd::cat::run(argv),
-            Command::Clipboard => cmd::clipboard::run(argv),
             Command::Count => cmd::count::run(argv),
             Command::Datefmt => cmd::datefmt::run(argv),
             Command::Dedup => cmd::dedup::run(argv),


Test patch:
diff --git a/tests/tests.rs b/tests/tests.rs
index 68bf74bbf..57480eb69 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -40,8 +40,9 @@ mod test_behead;
 #[cfg(any(feature = "feature_capable", feature = "lite"))]
 mod test_cat;
 #[cfg(all(
-    any(feature = "feature_capable", feature = "lite"),
-    any(target_os = "windows", target_os = "macos")
+    any(feature = "feature_capable"),
+    any(target_os = "windows", target_os = "macos"),
+    feature = "clipboard",
 ))]
 mod test_clipboard;
 mod test_combos;