mirror of
https://github.com/nushell/nushell.git
synced 2025-08-12 08:39:25 +02:00
Add select
This commit is contained in:
@ -13,6 +13,24 @@ pub struct CellPath {
|
||||
pub members: Vec<PathMember>,
|
||||
}
|
||||
|
||||
impl CellPath {
|
||||
pub fn into_string(&self) -> String {
|
||||
let mut output = String::new();
|
||||
|
||||
for (idx, elem) in self.members.iter().enumerate() {
|
||||
if idx > 0 {
|
||||
output.push('.');
|
||||
}
|
||||
match elem {
|
||||
PathMember::Int { val, .. } => output.push_str(&format!("{}", val)),
|
||||
PathMember::String { val, .. } => output.push_str(val),
|
||||
}
|
||||
}
|
||||
|
||||
output
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct FullCellPath {
|
||||
pub head: Expression,
|
||||
|
@ -191,7 +191,7 @@ impl Value {
|
||||
Value::Nothing { .. } => String::new(),
|
||||
Value::Error { error } => format!("{:?}", error),
|
||||
Value::Binary { val, .. } => format!("{:?}", val),
|
||||
Value::CellPath { val, .. } => format!("{:?}", val),
|
||||
Value::CellPath { val, .. } => val.into_string(),
|
||||
}
|
||||
}
|
||||
|
||||
@ -223,7 +223,7 @@ impl Value {
|
||||
Value::Nothing { .. } => String::new(),
|
||||
Value::Error { error } => format!("{:?}", error),
|
||||
Value::Binary { val, .. } => format!("{:?}", val),
|
||||
Value::CellPath { val, .. } => format!("{:?}", val),
|
||||
Value::CellPath { .. } => self.into_string(),
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user