forked from extern/nushell
WIP
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EvaluationContext};
|
||||
use nu_protocol::{Signature, Value};
|
||||
use nu_protocol::{IntoPipelineData, PipelineData, Signature, Value};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct Git;
|
||||
|
||||
impl Command for Git {
|
||||
@@ -21,8 +22,8 @@ impl Command for Git {
|
||||
&self,
|
||||
_context: &EvaluationContext,
|
||||
call: &Call,
|
||||
_input: Value,
|
||||
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
|
||||
_input: PipelineData,
|
||||
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||
use std::process::Command as ProcessCommand;
|
||||
use std::process::Stdio;
|
||||
|
||||
@@ -37,17 +38,18 @@ impl Command for Git {
|
||||
Ok(Value::String {
|
||||
val: String::from_utf8_lossy(&result).to_string(),
|
||||
span: call.head,
|
||||
})
|
||||
}
|
||||
.into_pipeline_data())
|
||||
}
|
||||
Err(_err) => {
|
||||
// FIXME: Move this to an external signature and add better error handling
|
||||
Ok(Value::nothing())
|
||||
Ok(PipelineData::new())
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(_err) => {
|
||||
// FIXME: Move this to an external signature and add better error handling
|
||||
Ok(Value::nothing())
|
||||
Ok(PipelineData::new())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,9 @@
|
||||
use nu_engine::eval_expression;
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EvaluationContext};
|
||||
use nu_protocol::{Signature, SyntaxShape, Value};
|
||||
use nu_protocol::{IntoPipelineData, PipelineData, Signature, SyntaxShape, Value};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct GitCheckout;
|
||||
|
||||
impl Command for GitCheckout {
|
||||
@@ -26,8 +27,8 @@ impl Command for GitCheckout {
|
||||
&self,
|
||||
context: &EvaluationContext,
|
||||
call: &Call,
|
||||
_input: Value,
|
||||
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
|
||||
_input: PipelineData,
|
||||
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||
use std::process::Command as ProcessCommand;
|
||||
use std::process::Stdio;
|
||||
|
||||
@@ -52,17 +53,18 @@ impl Command for GitCheckout {
|
||||
Ok(Value::String {
|
||||
val: String::from_utf8_lossy(&result).to_string(),
|
||||
span: call.head,
|
||||
})
|
||||
}
|
||||
.into_pipeline_data())
|
||||
}
|
||||
Err(_err) => {
|
||||
// FIXME: Move this to an external signature and add better error handling
|
||||
Ok(Value::nothing())
|
||||
Ok(PipelineData::new())
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(_err) => {
|
||||
// FIXME: Move this to an external signature and add better error handling
|
||||
Ok(Value::nothing())
|
||||
Ok(PipelineData::new())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -5,8 +5,11 @@ use std::process::Stdio;
|
||||
|
||||
use nu_protocol::ast::Call;
|
||||
use nu_protocol::engine::{Command, EvaluationContext};
|
||||
use nu_protocol::IntoPipelineData;
|
||||
use nu_protocol::PipelineData;
|
||||
use nu_protocol::{Signature, Value};
|
||||
|
||||
#[derive(Clone)]
|
||||
pub struct ListGitBranches;
|
||||
|
||||
//NOTE: this is not a real implementation :D. It's just a simple one to test with until we port the real one.
|
||||
@@ -27,8 +30,8 @@ impl Command for ListGitBranches {
|
||||
&self,
|
||||
_context: &EvaluationContext,
|
||||
call: &Call,
|
||||
_input: Value,
|
||||
) -> Result<nu_protocol::Value, nu_protocol::ShellError> {
|
||||
_input: PipelineData,
|
||||
) -> Result<nu_protocol::PipelineData, nu_protocol::ShellError> {
|
||||
let list_branches = ProcessCommand::new("git")
|
||||
.arg("branch")
|
||||
.stdout(Stdio::piped())
|
||||
@@ -55,15 +58,12 @@ impl Command for ListGitBranches {
|
||||
})
|
||||
.collect();
|
||||
|
||||
Ok(Value::List {
|
||||
vals: lines,
|
||||
span: call.head,
|
||||
})
|
||||
Ok(lines.into_iter().into_pipeline_data())
|
||||
} else {
|
||||
Ok(Value::Nothing { span: call.head })
|
||||
Ok(PipelineData::new())
|
||||
}
|
||||
} else {
|
||||
Ok(Value::Nothing { span: call.head })
|
||||
Ok(PipelineData::new())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user