diff --git a/Cargo.lock b/Cargo.lock index 2ad5b71d1..f52f6d56e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1503,18 +1503,6 @@ dependencies = [ "winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", ] -[[package]] -name = "nix" -version = "0.13.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -dependencies = [ - "bitflags 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)", - "cc 1.0.37 (registry+https://github.com/rust-lang/crates.io-index)", - "cfg-if 0.1.9 (registry+https://github.com/rust-lang/crates.io-index)", - "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", - "void 1.0.2 (registry+https://github.com/rust-lang/crates.io-index)", -] - [[package]] name = "nix" version = "0.14.0" @@ -1595,7 +1583,7 @@ dependencies = [ "ptree 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", "regex 1.1.6 (registry+https://github.com/rust-lang/crates.io-index)", "reqwest 0.9.18 (registry+https://github.com/rust-lang/crates.io-index)", - "rustyline 4.1.0 (registry+https://github.com/rust-lang/crates.io-index)", + "rustyline 4.1.0 (git+https://github.com/kkawakam/rustyline.git)", "serde 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", "serde-hjson 0.9.0 (registry+https://github.com/rust-lang/crates.io-index)", "serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)", @@ -2298,13 +2286,13 @@ dependencies = [ [[package]] name = "rustyline" version = "4.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" +source = "git+https://github.com/kkawakam/rustyline.git#cad8b2fc0b253831aaff143bdce5d2abec66a9c9" dependencies = [ - "dirs 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)", + "dirs 2.0.1 (registry+https://github.com/rust-lang/crates.io-index)", "libc 0.2.55 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.4.6 (registry+https://github.com/rust-lang/crates.io-index)", "memchr 2.2.0 (registry+https://github.com/rust-lang/crates.io-index)", - "nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)", + "nix 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-segmentation 1.3.0 (registry+https://github.com/rust-lang/crates.io-index)", "unicode-width 0.1.5 (registry+https://github.com/rust-lang/crates.io-index)", "utf8parse 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)", @@ -3324,7 +3312,6 @@ dependencies = [ "checksum native-tls 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "4b2df1a4c22fd44a62147fd8f13dd0f95c9d8ca7b2610299b2a2f9cf8964274e" "checksum ncurses 5.99.0 (registry+https://github.com/rust-lang/crates.io-index)" = "15699bee2f37e9f8828c7b35b2bc70d13846db453f2d507713b758fabe536b82" "checksum net2 0.2.33 (registry+https://github.com/rust-lang/crates.io-index)" = "42550d9fb7b6684a6d404d9fa7250c2eb2646df731d1c06afc06dcee9e1bcf88" -"checksum nix 0.13.0 (registry+https://github.com/rust-lang/crates.io-index)" = "46f0f3210768d796e8fa79ec70ee6af172dacbe7147f5e69be5240a47778302b" "checksum nix 0.14.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0d10caafde29a846a82ae0af70414e4643e072993441033b2c93217957e2f867" "checksum nodrop 0.1.13 (registry+https://github.com/rust-lang/crates.io-index)" = "2f9667ddcc6cc8a43afc9b7917599d7216aa09c463919ea32c59ed6cac8bc945" "checksum nom 4.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "2ad2a91a8e869eeb30b9cb3119ae87773a8f4ae617f41b1eb9c154b2905f7bd6" @@ -3401,7 +3388,7 @@ dependencies = [ "checksum rustc-demangle 0.1.14 (registry+https://github.com/rust-lang/crates.io-index)" = "ccc78bfd5acd7bf3e89cffcf899e5cb1a52d6fafa8dec2739ad70c9577a57288" "checksum rustc-hash 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "7540fc8b0c49f096ee9c961cda096467dce8084bec6bdca2fc83895fd9b28cb8" "checksum rustc_version 0.2.3 (registry+https://github.com/rust-lang/crates.io-index)" = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -"checksum rustyline 4.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "0f47ea1ceb347d2deae482d655dc8eef4bd82363d3329baffa3818bd76fea48b" +"checksum rustyline 4.1.0 (git+https://github.com/kkawakam/rustyline.git)" = "" "checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f" "checksum safemem 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8dca453248a96cb0749e36ccdfe2b0b4e54a61bfef89fb97ec621eb8e0a93dd9" "checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267" diff --git a/Cargo.toml b/Cargo.toml index 526790ea5..b9c9fb240 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -9,7 +9,8 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -rustyline = "4.1.0" +#rustyline = "4.1.0" +rustyline = { git ="https://github.com/kkawakam/rustyline.git" } sysinfo = "0.8.4" chrono = { version = "0.4.6", features = ["serde"] } chrono-tz = "0.5.1" diff --git a/src/cli.rs b/src/cli.rs index 71a84b09b..4bdffeb78 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -110,7 +110,7 @@ pub async fn cli() -> Result<(), Box> { let readline = rl.readline(&format!( "{}{}> ", - context.env.lock().unwrap().cwd().display().to_string(), + context.env.lock().unwrap().cwd().display(), match current_branch() { Some(s) => format!("({})", s), None => "".to_string(), @@ -213,7 +213,7 @@ async fn process_line(readline: Result, ctx: &mut Context Ok(line) => { let result = match crate::parser::parse(&line) { Err(err) => { - return LineResult::Error(line.to_string(), err); + return LineResult::Error(line.clone(), err); } Ok(val) => val, @@ -249,19 +249,19 @@ async fn process_line(readline: Result, ctx: &mut Context (None, _) => break, (Some(ClassifiedCommand::Expr(_)), _) => { - return LineResult::Error(line.to_string(), ShellError::unimplemented( + return LineResult::Error(line.clone(), ShellError::unimplemented( "Expression-only commands", )) } (_, Some(ClassifiedCommand::Expr(_))) => { - return LineResult::Error(line.to_string(), ShellError::unimplemented( + return LineResult::Error(line.clone(), ShellError::unimplemented( "Expression-only commands", )) } (Some(ClassifiedCommand::Sink(_)), Some(_)) => { - return LineResult::Error(line.to_string(), ShellError::string("Commands like table, save, and autoview must come last in the pipeline")) + return LineResult::Error(line.clone(), ShellError::string("Commands like table, save, and autoview must come last in the pipeline")) } (Some(ClassifiedCommand::Sink(left)), None) => { @@ -278,7 +278,7 @@ async fn process_line(readline: Result, ctx: &mut Context Some(ClassifiedCommand::External(_)), ) => match left.run(ctx, input).await { Ok(val) => ClassifiedInputStream::from_input_stream(val), - Err(err) => return LineResult::Error(line.to_string(), err), + Err(err) => return LineResult::Error(line.clone(), err), }, ( @@ -286,13 +286,13 @@ async fn process_line(readline: Result, ctx: &mut Context Some(_), ) => match left.run(ctx, input).await { Ok(val) => ClassifiedInputStream::from_input_stream(val), - Err(err) => return LineResult::Error(line.to_string(), err), + Err(err) => return LineResult::Error(line.clone(), err), }, (Some(ClassifiedCommand::Internal(left)), None) => { match left.run(ctx, input).await { Ok(val) => ClassifiedInputStream::from_input_stream(val), - Err(err) => return LineResult::Error(line.to_string(), err), + Err(err) => return LineResult::Error(line.clone(), err), } } @@ -301,7 +301,7 @@ async fn process_line(readline: Result, ctx: &mut Context Some(ClassifiedCommand::External(_)), ) => match left.run(ctx, input, StreamNext::External).await { Ok(val) => val, - Err(err) => return LineResult::Error(line.to_string(), err), + Err(err) => return LineResult::Error(line.clone(), err), }, ( @@ -309,19 +309,19 @@ async fn process_line(readline: Result, ctx: &mut Context Some(_), ) => match left.run(ctx, input, StreamNext::Internal).await { Ok(val) => val, - Err(err) => return LineResult::Error(line.to_string(), err), + Err(err) => return LineResult::Error(line.clone(), err), }, (Some(ClassifiedCommand::External(left)), None) => { match left.run(ctx, input, StreamNext::Last).await { Ok(val) => val, - Err(err) => return LineResult::Error(line.to_string(), err), + Err(err) => return LineResult::Error(line.clone(), err), } } } } - LineResult::Success(line.to_string()) + LineResult::Success(line.clone()) } Err(ReadlineError::Interrupted) => { LineResult::Error("".to_string(), ShellError::string("CTRL-C")) diff --git a/src/object/base.rs b/src/object/base.rs index acd1ce167..f0ec46168 100644 --- a/src/object/base.rs +++ b/src/object/base.rs @@ -266,7 +266,7 @@ impl Value { crate fn as_string(&self) -> Result { match self { - Value::Primitive(Primitive::String(s)) => Ok(s.to_string()), + Value::Primitive(Primitive::String(s)) => Ok(s.clone()), // TODO: this should definitely be more general with better errors other => Err(ShellError::string(format!( "Expected string, got {:?}", diff --git a/src/parser/ast.rs b/src/parser/ast.rs index 640c5e95e..b827cd5e7 100644 --- a/src/parser/ast.rs +++ b/src/parser/ast.rs @@ -527,7 +527,7 @@ impl RawExpression { crate fn as_string(&self) -> Option { match self { - RawExpression::Leaf(Leaf::String(s)) => Some(s.to_string()), + RawExpression::Leaf(Leaf::String(s)) => Some(s.clone()), RawExpression::Leaf(Leaf::Bare(path)) => Some(path.to_string()), _ => None, } @@ -737,9 +737,9 @@ impl Leaf { fn as_external_arg(&self) -> String { match self { Leaf::String(s) => format!("\"{}\"", s), - Leaf::Bare(path) => format!("{}", path.to_string()), - Leaf::Boolean(b) => format!("{}", b), - Leaf::Int(i) => format!("{}", i), + Leaf::Bare(path) => path.to_string(), + Leaf::Boolean(b) => b.to_string(), + Leaf::Int(i) => i.to_string(), Leaf::Unit(i, unit) => format!("{}{:?}", i, unit), } } diff --git a/src/shell/completer.rs b/src/shell/completer.rs index 03351a0db..6501ff98b 100644 --- a/src/shell/completer.rs +++ b/src/shell/completer.rs @@ -19,7 +19,6 @@ impl Completer for NuCompleter { pos: usize, context: &rustyline::Context, ) -> rustyline::Result<(usize, Vec)> { - let commands: Vec = self.commands.keys().cloned().collect(); let mut completions = self.file_completer.complete(line, pos, context)?.1; @@ -51,8 +50,8 @@ impl Completer for NuCompleter { if matched { completions.push(completion::Pair { - display: command.to_string(), - replacement: command.to_string(), + display: command.clone(), + replacement: command.clone(), }); } } diff --git a/src/shell/helper.rs b/src/shell/helper.rs index c930d9fff..039a0b719 100644 --- a/src/shell/helper.rs +++ b/src/shell/helper.rs @@ -47,7 +47,7 @@ impl Hinter for Helper { } impl Highlighter for Helper { - fn highlight_prompt<'p>(&self, prompt: &'p str) -> Cow<'p, str> { + fn highlight_prompt<'b, 's: 'b, 'p:'b>(&'s self, prompt: &'p str, _: bool) -> Cow<'b, str> { Owned("\x1b[32m".to_owned() + &prompt[0..prompt.len() - 2] + "\x1b[m> ") }