mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 00:44:57 +02:00
Batch of dataframe commands (#442)
* corrected missing shellerror type * batch dataframe commands * removed option to find declaration with input * ordered dataframe folders
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
use super::Command;
|
||||
use crate::{
|
||||
ast::Block, BlockId, DeclId, Example, Overlay, OverlayId, PipelineData, ShellError, Signature,
|
||||
Span, Type, Value, VarId,
|
||||
ast::Block, BlockId, DeclId, Example, Overlay, OverlayId, ShellError, Signature, Span, Type,
|
||||
VarId,
|
||||
};
|
||||
use core::panic;
|
||||
use std::{
|
||||
@ -370,39 +370,6 @@ impl EngineState {
|
||||
.expect("internal error: missing declaration")
|
||||
}
|
||||
|
||||
#[allow(clippy::borrowed_box)]
|
||||
pub fn get_decl_with_input(&self, decl_id: DeclId, input: &PipelineData) -> &Box<dyn Command> {
|
||||
let decl = self.get_decl(decl_id);
|
||||
|
||||
match input {
|
||||
PipelineData::Stream(..) => decl,
|
||||
PipelineData::Value(value, ..) => match value {
|
||||
Value::CustomValue { val, .. } => {
|
||||
// This filter works because the custom definitions were declared
|
||||
// before the default nushell declarations. This means that the custom
|
||||
// declarations that get overridden by the default declarations can only
|
||||
// be accessed if the input value has the required category
|
||||
let decls = self
|
||||
.decls
|
||||
.iter()
|
||||
.enumerate()
|
||||
.filter(|(_, decl_inner)| {
|
||||
decl.name() == decl_inner.name()
|
||||
&& decl_inner.signature().category == val.category()
|
||||
})
|
||||
.map(|(index, _)| index)
|
||||
.collect::<Vec<usize>>();
|
||||
|
||||
match decls.first() {
|
||||
Some(index) => self.get_decl(*index),
|
||||
None => decl,
|
||||
}
|
||||
}
|
||||
_ => decl,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
/// Get all IDs of all commands within scope, sorted by the commads' names
|
||||
pub fn get_decl_ids_sorted(&self, include_hidden: bool) -> impl Iterator<Item = DeclId> {
|
||||
let mut decls_map = HashMap::new();
|
||||
|
@ -30,7 +30,9 @@ pub trait CustomValue: fmt::Debug + Send + Sync {
|
||||
fn follow_path_string(&self, column_name: String, span: Span) -> Result<Value, ShellError>;
|
||||
|
||||
// ordering with other value
|
||||
fn partial_cmp(&self, other: &Value) -> Option<Ordering>;
|
||||
fn partial_cmp(&self, _other: &Value) -> Option<Ordering> {
|
||||
None
|
||||
}
|
||||
|
||||
// Definition of an operation between the object that implements the trait
|
||||
// and another Value.
|
||||
|
Reference in New Issue
Block a user