mirror of
https://github.com/nushell/nushell.git
synced 2025-08-10 10:38:07 +02:00
introducing gstat
, a new command to get the git status (#443)
* wip - preliminary checking * updated to latest pluging * i think it's all working now, except bare words * clippy
This commit is contained in:
28
crates/nu_plugin_gstat/src/nu/mod.rs
Normal file
28
crates/nu_plugin_gstat/src/nu/mod.rs
Normal file
@ -0,0 +1,28 @@
|
||||
use crate::GStat;
|
||||
use nu_plugin::{EvaluatedCall, LabeledError, Plugin};
|
||||
use nu_protocol::{Signature, Span, Spanned, SyntaxShape, Value};
|
||||
|
||||
impl Plugin for GStat {
|
||||
fn signature(&self) -> Vec<Signature> {
|
||||
vec![Signature::build("gstat")
|
||||
.desc("Get the git status of a repo")
|
||||
.optional("path", SyntaxShape::String, "path to repo")]
|
||||
}
|
||||
|
||||
fn run(
|
||||
&mut self,
|
||||
name: &str,
|
||||
call: &EvaluatedCall,
|
||||
input: &Value,
|
||||
) -> Result<Value, LabeledError> {
|
||||
if name != "gstat" {
|
||||
return Ok(Value::Nothing {
|
||||
span: Span::unknown(),
|
||||
});
|
||||
}
|
||||
|
||||
let repo_path: Option<Spanned<String>> = call.opt(0)?;
|
||||
// eprintln!("input value: {:#?}", &input);
|
||||
self.gstat(input, repo_path, &call.head)
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user