mirror of
https://github.com/nushell/nushell.git
synced 2025-03-22 11:37:10 +01:00
Refactor header extraction
This commit is contained in:
parent
ec0bd20f29
commit
1b9c006696
@ -44,22 +44,18 @@ pub fn count(
|
||||
let stream = async_stream! {
|
||||
let rows: Vec<Value> = input.values.collect().await;
|
||||
|
||||
let mut entries = IndexMap::new();
|
||||
let headers: Value = rows[0].clone();
|
||||
match &headers.value {
|
||||
let mut headers = vec![];
|
||||
match &rows[0].value {
|
||||
UntaggedValue::Row(d) => {
|
||||
entries = d.entries.clone();
|
||||
()
|
||||
for (_, v) in d.entries.iter() {
|
||||
headers.push(v.as_string().unwrap());
|
||||
}
|
||||
}
|
||||
_ => ()
|
||||
}
|
||||
let mut heads = vec![];
|
||||
for (k, v) in entries.iter() {
|
||||
heads.push(v.as_string().unwrap());
|
||||
}
|
||||
|
||||
let mut file = File::create("headout").unwrap();
|
||||
write!(file, "args: {:#?}", heads);
|
||||
write!(file, "args: {:#?}", headers);
|
||||
|
||||
yield ReturnSuccess::value(UntaggedValue::int(rows.len()).into_value(name))
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user