mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 12:25:58 +02:00
move get_columns from the table_viewer to a central location (#628)
* get_columns is working in the columns command * the new location of the get_columns method is nu-protocol/src/column.rs * reference the new location of the get_columns method * move get_columns to nu-engine
This commit is contained in:
17
crates/nu-engine/src/column.rs
Normal file
17
crates/nu-engine/src/column.rs
Normal file
@ -0,0 +1,17 @@
|
||||
use nu_protocol::Value;
|
||||
|
||||
pub fn get_columns(input: &[Value]) -> Vec<String> {
|
||||
let mut columns = vec![];
|
||||
|
||||
for item in input {
|
||||
if let Value::Record { cols, vals: _, .. } = item {
|
||||
for col in cols {
|
||||
if !columns.contains(col) {
|
||||
columns.push(col.to_string());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
columns
|
||||
}
|
@ -1,9 +1,11 @@
|
||||
mod call_ext;
|
||||
pub mod column;
|
||||
mod documentation;
|
||||
mod env;
|
||||
mod eval;
|
||||
|
||||
pub use call_ext::CallExt;
|
||||
pub use column::get_columns;
|
||||
pub use documentation::{generate_docs, get_brief_help, get_documentation, get_full_help};
|
||||
pub use env::*;
|
||||
pub use eval::{eval_block, eval_expression, eval_operator};
|
||||
|
Reference in New Issue
Block a user