mirror of
https://github.com/nushell/nushell.git
synced 2024-11-25 01:43:47 +01:00
Cleanup and bump rustyline
This commit is contained in:
parent
dfd2a6b1a9
commit
62fac11e07
23
Cargo.lock
generated
23
Cargo.lock
generated
@ -1503,18 +1503,6 @@ dependencies = [
|
|||||||
"winapi 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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]]
|
[[package]]
|
||||||
name = "nix"
|
name = "nix"
|
||||||
version = "0.14.0"
|
version = "0.14.0"
|
||||||
@ -1595,7 +1583,7 @@ dependencies = [
|
|||||||
"ptree 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)",
|
"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)",
|
"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)",
|
"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 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-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)",
|
"serde_derive 1.0.91 (registry+https://github.com/rust-lang/crates.io-index)",
|
||||||
@ -2298,13 +2286,13 @@ dependencies = [
|
|||||||
[[package]]
|
[[package]]
|
||||||
name = "rustyline"
|
name = "rustyline"
|
||||||
version = "4.1.0"
|
version = "4.1.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "git+https://github.com/kkawakam/rustyline.git#cad8b2fc0b253831aaff143bdce5d2abec66a9c9"
|
||||||
dependencies = [
|
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)",
|
"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)",
|
"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)",
|
"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-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)",
|
"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)",
|
"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 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 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 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 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 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"
|
"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-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-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 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)" = "<none>"
|
||||||
"checksum ryu 0.2.8 (registry+https://github.com/rust-lang/crates.io-index)" = "b96a9549dc8d48f2c283938303c4b5a77aa29bfbc5b54b084fb1630408899a8f"
|
"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 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"
|
"checksum same-file 1.0.4 (registry+https://github.com/rust-lang/crates.io-index)" = "8f20c4be53a8a1ff4c1f1b2bd14570d2f634628709752f0702ecdd2b3f9a5267"
|
||||||
|
@ -9,7 +9,8 @@ edition = "2018"
|
|||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
rustyline = "4.1.0"
|
#rustyline = "4.1.0"
|
||||||
|
rustyline = { git ="https://github.com/kkawakam/rustyline.git" }
|
||||||
sysinfo = "0.8.4"
|
sysinfo = "0.8.4"
|
||||||
chrono = { version = "0.4.6", features = ["serde"] }
|
chrono = { version = "0.4.6", features = ["serde"] }
|
||||||
chrono-tz = "0.5.1"
|
chrono-tz = "0.5.1"
|
||||||
|
24
src/cli.rs
24
src/cli.rs
@ -110,7 +110,7 @@ pub async fn cli() -> Result<(), Box<dyn Error>> {
|
|||||||
|
|
||||||
let readline = rl.readline(&format!(
|
let readline = rl.readline(&format!(
|
||||||
"{}{}> ",
|
"{}{}> ",
|
||||||
context.env.lock().unwrap().cwd().display().to_string(),
|
context.env.lock().unwrap().cwd().display(),
|
||||||
match current_branch() {
|
match current_branch() {
|
||||||
Some(s) => format!("({})", s),
|
Some(s) => format!("({})", s),
|
||||||
None => "".to_string(),
|
None => "".to_string(),
|
||||||
@ -213,7 +213,7 @@ async fn process_line(readline: Result<String, ReadlineError>, ctx: &mut Context
|
|||||||
Ok(line) => {
|
Ok(line) => {
|
||||||
let result = match crate::parser::parse(&line) {
|
let result = match crate::parser::parse(&line) {
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
return LineResult::Error(line.to_string(), err);
|
return LineResult::Error(line.clone(), err);
|
||||||
}
|
}
|
||||||
|
|
||||||
Ok(val) => val,
|
Ok(val) => val,
|
||||||
@ -249,19 +249,19 @@ async fn process_line(readline: Result<String, ReadlineError>, ctx: &mut Context
|
|||||||
(None, _) => break,
|
(None, _) => break,
|
||||||
|
|
||||||
(Some(ClassifiedCommand::Expr(_)), _) => {
|
(Some(ClassifiedCommand::Expr(_)), _) => {
|
||||||
return LineResult::Error(line.to_string(), ShellError::unimplemented(
|
return LineResult::Error(line.clone(), ShellError::unimplemented(
|
||||||
"Expression-only commands",
|
"Expression-only commands",
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
(_, Some(ClassifiedCommand::Expr(_))) => {
|
(_, Some(ClassifiedCommand::Expr(_))) => {
|
||||||
return LineResult::Error(line.to_string(), ShellError::unimplemented(
|
return LineResult::Error(line.clone(), ShellError::unimplemented(
|
||||||
"Expression-only commands",
|
"Expression-only commands",
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
(Some(ClassifiedCommand::Sink(_)), Some(_)) => {
|
(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) => {
|
(Some(ClassifiedCommand::Sink(left)), None) => {
|
||||||
@ -278,7 +278,7 @@ async fn process_line(readline: Result<String, ReadlineError>, ctx: &mut Context
|
|||||||
Some(ClassifiedCommand::External(_)),
|
Some(ClassifiedCommand::External(_)),
|
||||||
) => match left.run(ctx, input).await {
|
) => match left.run(ctx, input).await {
|
||||||
Ok(val) => ClassifiedInputStream::from_input_stream(val),
|
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<String, ReadlineError>, ctx: &mut Context
|
|||||||
Some(_),
|
Some(_),
|
||||||
) => match left.run(ctx, input).await {
|
) => match left.run(ctx, input).await {
|
||||||
Ok(val) => ClassifiedInputStream::from_input_stream(val),
|
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) => {
|
(Some(ClassifiedCommand::Internal(left)), None) => {
|
||||||
match left.run(ctx, input).await {
|
match left.run(ctx, input).await {
|
||||||
Ok(val) => ClassifiedInputStream::from_input_stream(val),
|
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<String, ReadlineError>, ctx: &mut Context
|
|||||||
Some(ClassifiedCommand::External(_)),
|
Some(ClassifiedCommand::External(_)),
|
||||||
) => match left.run(ctx, input, StreamNext::External).await {
|
) => match left.run(ctx, input, StreamNext::External).await {
|
||||||
Ok(val) => val,
|
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<String, ReadlineError>, ctx: &mut Context
|
|||||||
Some(_),
|
Some(_),
|
||||||
) => match left.run(ctx, input, StreamNext::Internal).await {
|
) => match left.run(ctx, input, StreamNext::Internal).await {
|
||||||
Ok(val) => val,
|
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) => {
|
(Some(ClassifiedCommand::External(left)), None) => {
|
||||||
match left.run(ctx, input, StreamNext::Last).await {
|
match left.run(ctx, input, StreamNext::Last).await {
|
||||||
Ok(val) => val,
|
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) => {
|
Err(ReadlineError::Interrupted) => {
|
||||||
LineResult::Error("".to_string(), ShellError::string("CTRL-C"))
|
LineResult::Error("".to_string(), ShellError::string("CTRL-C"))
|
||||||
|
@ -266,7 +266,7 @@ impl Value {
|
|||||||
|
|
||||||
crate fn as_string(&self) -> Result<String, ShellError> {
|
crate fn as_string(&self) -> Result<String, ShellError> {
|
||||||
match self {
|
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
|
// TODO: this should definitely be more general with better errors
|
||||||
other => Err(ShellError::string(format!(
|
other => Err(ShellError::string(format!(
|
||||||
"Expected string, got {:?}",
|
"Expected string, got {:?}",
|
||||||
|
@ -527,7 +527,7 @@ impl RawExpression {
|
|||||||
|
|
||||||
crate fn as_string(&self) -> Option<String> {
|
crate fn as_string(&self) -> Option<String> {
|
||||||
match self {
|
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()),
|
RawExpression::Leaf(Leaf::Bare(path)) => Some(path.to_string()),
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
@ -737,9 +737,9 @@ impl Leaf {
|
|||||||
fn as_external_arg(&self) -> String {
|
fn as_external_arg(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
Leaf::String(s) => format!("\"{}\"", s),
|
Leaf::String(s) => format!("\"{}\"", s),
|
||||||
Leaf::Bare(path) => format!("{}", path.to_string()),
|
Leaf::Bare(path) => path.to_string(),
|
||||||
Leaf::Boolean(b) => format!("{}", b),
|
Leaf::Boolean(b) => b.to_string(),
|
||||||
Leaf::Int(i) => format!("{}", i),
|
Leaf::Int(i) => i.to_string(),
|
||||||
Leaf::Unit(i, unit) => format!("{}{:?}", i, unit),
|
Leaf::Unit(i, unit) => format!("{}{:?}", i, unit),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,6 @@ impl Completer for NuCompleter {
|
|||||||
pos: usize,
|
pos: usize,
|
||||||
context: &rustyline::Context,
|
context: &rustyline::Context,
|
||||||
) -> rustyline::Result<(usize, Vec<completion::Pair>)> {
|
) -> rustyline::Result<(usize, Vec<completion::Pair>)> {
|
||||||
|
|
||||||
let commands: Vec<String> = self.commands.keys().cloned().collect();
|
let commands: Vec<String> = self.commands.keys().cloned().collect();
|
||||||
|
|
||||||
let mut completions = self.file_completer.complete(line, pos, context)?.1;
|
let mut completions = self.file_completer.complete(line, pos, context)?.1;
|
||||||
@ -51,8 +50,8 @@ impl Completer for NuCompleter {
|
|||||||
|
|
||||||
if matched {
|
if matched {
|
||||||
completions.push(completion::Pair {
|
completions.push(completion::Pair {
|
||||||
display: command.to_string(),
|
display: command.clone(),
|
||||||
replacement: command.to_string(),
|
replacement: command.clone(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ impl Hinter for Helper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl Highlighter 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> ")
|
Owned("\x1b[32m".to_owned() + &prompt[0..prompt.len() - 2] + "\x1b[m> ")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user