Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
term, cli: `winsplit` over `shlex` on Windows
✗ CI failure Lorenz Leutgeb committed 2 months ago
commit da69bd04a21eec4a40e8c923d007be5f9954f3c4
parent 1cab036c331f5ac071f002504c44b01e95b8f25a
2 failed (2 total) View logs
7 files changed +37 -5
modified Cargo.lock
@@ -2888,6 +2888,7 @@ dependencies = [
 "tree-sitter-rust",
 "tree-sitter-toml-ng",
 "tree-sitter-typescript",
+
 "winsplit",
 "zeroize",
]

@@ -3200,6 +3201,7 @@ dependencies = [
 "thiserror 2.0.17",
 "unicode-display-width",
 "unicode-segmentation",
+
 "winsplit",
 "zeroize",
]

@@ -5107,6 +5109,12 @@ dependencies = [
]

[[package]]
+
name = "winsplit"
+
version = "0.1.0"
+
source = "registry+https://github.com/rust-lang/crates.io-index"
+
checksum = "3ab703352da6a72f35c39a533526393725640575bb211f61987a2748323ad956"
+

+
[[package]]
name = "wit-bindgen-rt"
version = "0.39.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
modified Cargo.toml
@@ -69,6 +69,7 @@ sqlite = "0.32.0"
tempfile = "3.3.0"
thiserror = { version = "2", default-features = false }
winpipe = "0.1.1"
+
winsplit = "0.1.0"
zeroize = "1.5.7"

# Crates from the "radicle-git" workspace. These should be synced manually.
modified crates/radicle-cli-test/src/lib.rs
@@ -10,6 +10,11 @@ use snapbox::cmd::{Command, OutputAssert};
use snapbox::{Assert, Substitutions};
use thiserror::Error;

+
#[cfg(unix)]
+
use shlex::split;
+
#[cfg(windows)]
+
use winsplit::split;
+

/// Used to ensure the build task is only run once.
static BUILD: sync::Once = sync::Once::new();

@@ -347,7 +352,7 @@ impl TestFormula {
                    content.push('\n');
                } else if let Some(line) = line.strip_prefix('$') {
                    let line = line.trim();
-
                    let parts = shlex::split(line).ok_or(Error::Parse)?;
+
                    let parts = split(line).ok_or(Error::Parse)?;
                    let (cmd, args) = parts.split_first().ok_or(Error::Parse)?;

                    test.assertions.push(Assertion {
modified crates/radicle-cli/Cargo.toml
@@ -33,7 +33,6 @@ radicle-term = { workspace = true }
schemars = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
-
shlex = { workspace = true }
tempfile = { workspace = true }
thiserror = { workspace = true, default-features = true }
timeago = { version = "0.4.2", default-features = false }
@@ -53,6 +52,12 @@ tree-sitter-toml-ng = "0.6.0"
tree-sitter-typescript = "0.23.2"
zeroize = { workspace = true }

+
[target.'cfg(unix)'.dependencies]
+
shlex = { workspace = true }
+

+
[target.'cfg(windows)'.dependencies]
+
winsplit = { workspace = true }
+

[dev-dependencies]
pretty_assertions = { workspace = true }
radicle = { workspace = true, features = ["test"] }
modified crates/radicle-cli/src/pager.rs
@@ -1,6 +1,11 @@
use std::io;
use std::process::{Command, Stdio};

+
#[cfg(unix)]
+
use shlex::split;
+
#[cfg(windows)]
+
use winsplit::split;
+

use radicle_term::element;
use radicle_term::{Constraint, Element};

@@ -21,7 +26,7 @@ pub fn run(elem: impl Element) -> io::Result<()> {
    let Some(pager) = radicle::profile::env::pager() else {
        return elem.write(Constraint::UNBOUNDED);
    };
-
    let Some(parts) = shlex::split(&pager) else {
+
    let Some(parts) = split(&pager) else {
        return elem.write(Constraint::UNBOUNDED);
    };
    let Some((program, args)) = parts.split_first() else {
modified crates/radicle-term/Cargo.toml
@@ -25,12 +25,15 @@ unicode-display-width = "0.3.0"
unicode-segmentation = "1.7.1"
zeroize = { workspace = true }
git2 = { workspace = true, optional = true }
-
shlex = { workspace = true }

[target.'cfg(unix)'.dependencies]
crossbeam-channel = { workspace = true }
libc = { workspace = true }
radicle-signals = { workspace = true }
+
shlex = { workspace = true }
+

+
[target.'cfg(windows)'.dependencies]
+
winsplit = { workspace = true }

[dev-dependencies]
pretty_assertions = { workspace = true }
modified crates/radicle-term/src/editor.rs
@@ -5,6 +5,11 @@ use std::path::{Path, PathBuf};
use std::process;
use std::{env, fs, io};

+
#[cfg(windows)]
+
use winsplit::split;
+
#[cfg(unix)]
+
use shlex::split;
+

/// Allows for text input in the configured editor.
pub struct Editor {
    path: PathBuf,
@@ -110,7 +115,7 @@ impl Editor {
                "editor not configured: the `EDITOR` environment variable is not set",
            ));
        };
-
        let Some(parts) = shlex::split(cmd.to_string_lossy().as_ref()) else {
+
        let Some(parts) = split(cmd.to_string_lossy().as_ref()) else {
            return Err(io::Error::new(
                io::ErrorKind::InvalidInput,
                format!("invalid editor command {cmd:?}"),