Ian Manske 583ef8674e
Replace &Span with Span since Span is Copy (#9770)
# Description
`Span` is `Copy`, so we probably should not be passing references of
`Span` around. This PR replaces all instances of `&Span` with `Span`,
copying spans where necessary.

# User-Facing Changes
This alters some public functions to take `Span` instead of `&Span` as
input. Namely, `EngineState::get_span_contents`,
`nu_protocol::extract_value`, a bunch of the math commands, and
`Gstat::gstat`.
2023-07-31 21:47:46 +02:00

28 lines
870 B
Rust

use crate::GStat;
use nu_plugin::{EvaluatedCall, LabeledError, Plugin};
use nu_protocol::{Category, PluginSignature, Spanned, SyntaxShape, Value};
impl Plugin for GStat {
fn signature(&self) -> Vec<PluginSignature> {
vec![PluginSignature::build("gstat")
.usage("Get the git status of a repo")
.optional("path", SyntaxShape::Filepath, "path to repo")
.category(Category::Custom("prompt".to_string()))]
}
fn run(
&mut self,
name: &str,
call: &EvaluatedCall,
input: &Value,
) -> Result<Value, LabeledError> {
if name != "gstat" {
return Ok(Value::Nothing { span: call.head });
}
let repo_path: Option<Spanned<String>> = call.opt(0)?;
// eprintln!("input value: {:#?}", &input);
self.gstat(input, repo_path, call.head)
}
}