2021-12-06 17:28:11 +00:00
|
|
|
use crate::GStat;
|
|
|
|
use nu_plugin::{EvaluatedCall, LabeledError, Plugin};
|
2021-12-19 07:46:13 +00:00
|
|
|
use nu_protocol::{Category, Signature, Spanned, SyntaxShape, Value};
|
2021-12-06 17:28:11 +00:00
|
|
|
|
|
|
|
impl Plugin for GStat {
|
|
|
|
fn signature(&self) -> Vec<Signature> {
|
|
|
|
vec![Signature::build("gstat")
|
2022-03-27 19:25:30 +00:00
|
|
|
.usage("Get the git status of a repo")
|
2022-03-22 18:32:03 +00:00
|
|
|
.optional("path", SyntaxShape::Filepath, "path to repo")
|
2021-12-07 20:06:34 +00:00
|
|
|
.category(Category::Custom("Prompt".to_string()))]
|
2021-12-06 17:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
fn run(
|
|
|
|
&mut self,
|
|
|
|
name: &str,
|
|
|
|
call: &EvaluatedCall,
|
|
|
|
input: &Value,
|
|
|
|
) -> Result<Value, LabeledError> {
|
|
|
|
if name != "gstat" {
|
2021-12-19 07:46:13 +00:00
|
|
|
return Ok(Value::Nothing { span: call.head });
|
2021-12-06 17:28:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
let repo_path: Option<Spanned<String>> = call.opt(0)?;
|
|
|
|
// eprintln!("input value: {:#?}", &input);
|
|
|
|
self.gstat(input, repo_path, &call.head)
|
|
|
|
}
|
|
|
|
}
|