MCPcopy Create free account
hub / github.com/Euphrasiologist/nu_plugin_plot / run

Method run

src/lib.rs:412–440  ·  view source on GitHub ↗
(
        &self,
        _plugin: &Self::Plugin,
        _engine: &nu_plugin::EngineInterface,
        call: &EvaluatedCall,
        input: &Value,
    )

Source from the content-addressed store, hash-verified

410 }
411
412 fn run(
413 &self,
414 _plugin: &Self::Plugin,
415 _engine: &nu_plugin::EngineInterface,
416 call: &EvaluatedCall,
417 input: &Value,
418 ) -> Result<Value, LabeledError> {
419 match input.as_list() {
420 Ok(list) => {
421 if list.is_empty() {
422 return Err(LabeledError::new("Can't plot a zero element list.").with_label( "No elements in the list.", call.head));
423 }
424 let (value_type, list_len_op) = check_equality_of_list(list, call)?;
425
426 // if in fact we have a nested list
427 if let Some(_len) = list_len_op {
428 // we haven't implemented this yet
429 self.plot_nested(call, input)
430 } else {
431 // we have a normal plot, single list of numbers
432 match value_type {
433 Type::Float | Type::Int => self.plot(call, input),
434 e => Err(LabeledError::new(format!("List type is {}, but should be float or int.", e)).with_label("Incorrect List type.", call.head)),
435 }
436 }
437 },
438 Err(e) => Err(LabeledError::new(format!("Input type should be a list: {}.", e)).with_label( "Incorrect input type.", call.head)),
439 }
440 }
441}
442
443impl Plotter for CommandHist {

Callers

nothing calls this directly

Calls 3

check_equality_of_listFunction · 0.85
plot_nestedMethod · 0.80
plotMethod · 0.80

Tested by

no test coverage detected