forked from extern/nushell
Nu has many commands that allow the nuño to customize behavior such as UI and behavior. Today, coloring can be customized, the line editor, and other things. The more options there are, the higher the complexity in managing them. To mitigate this Nu can store configuration options as nested properties. But to add and edit them can be taxing. With column path support we can work with them easier.
51 lines
1.0 KiB
Rust
51 lines
1.0 KiB
Rust
pub mod commands;
|
|
pub mod fs;
|
|
pub mod macros;
|
|
pub mod playground;
|
|
pub mod value;
|
|
|
|
pub fn pipeline(commands: &str) -> String {
|
|
commands
|
|
.lines()
|
|
.skip(1)
|
|
.map(|line| line.trim())
|
|
.collect::<Vec<&str>>()
|
|
.join(" ")
|
|
.trim_end()
|
|
.to_string()
|
|
}
|
|
|
|
pub fn shell_os_paths() -> Vec<std::path::PathBuf> {
|
|
let mut original_paths = vec![];
|
|
|
|
if let Some(paths) = std::env::var_os("PATH") {
|
|
original_paths = std::env::split_paths(&paths).collect::<Vec<_>>();
|
|
}
|
|
|
|
original_paths
|
|
}
|
|
|
|
#[cfg(test)]
|
|
mod tests {
|
|
use super::pipeline;
|
|
|
|
#[test]
|
|
fn constructs_a_pipeline() {
|
|
let actual = pipeline(
|
|
r#"
|
|
open los_tres_amigos.txt
|
|
| from-csv
|
|
| get rusty_luck
|
|
| str to-int
|
|
| math sum
|
|
| echo "$it"
|
|
"#,
|
|
);
|
|
|
|
assert_eq!(
|
|
actual,
|
|
r#"open los_tres_amigos.txt | from-csv | get rusty_luck | str to-int | math sum | echo "$it""#
|
|
);
|
|
}
|
|
}
|