mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 09:35:44 +02:00
This reverts commit e66bf70589
.
This commit is contained in:
34
src/main.rs
34
src/main.rs
@ -4,7 +4,7 @@ use nu_cli::create_default_context;
|
||||
use nu_cli::utils::test_bins as binaries;
|
||||
use std::error::Error;
|
||||
use std::fs::File;
|
||||
use std::io::prelude::*;
|
||||
use std::io::{prelude::*, BufReader};
|
||||
|
||||
fn main() -> Result<(), Box<dyn Error>> {
|
||||
let matches = App::new("nushell")
|
||||
@ -124,12 +124,9 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
match matches.values_of("commands") {
|
||||
None => {}
|
||||
Some(values) => {
|
||||
let script_text: String = values
|
||||
.map(|x| x.to_string())
|
||||
.collect::<Vec<String>>()
|
||||
.join("\n");
|
||||
futures::executor::block_on(nu_cli::run_script_file(
|
||||
script_text,
|
||||
let pipelines: Vec<String> = values.map(|x| x.to_string()).collect();
|
||||
futures::executor::block_on(nu_cli::run_vec_of_pipelines(
|
||||
pipelines,
|
||||
matches.is_present("stdin"),
|
||||
))?;
|
||||
return Ok(());
|
||||
@ -138,12 +135,25 @@ fn main() -> Result<(), Box<dyn Error>> {
|
||||
|
||||
match matches.value_of("script") {
|
||||
Some(script) => {
|
||||
let mut file = File::open(script)?;
|
||||
let mut buffer = String::new();
|
||||
file.read_to_string(&mut buffer)?;
|
||||
let file = File::open(script)?;
|
||||
let reader = BufReader::new(file);
|
||||
let pipelines: Vec<String> = reader
|
||||
.lines()
|
||||
.filter_map(|x| {
|
||||
if let Ok(x) = x {
|
||||
if !x.starts_with('#') {
|
||||
Some(x)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.collect();
|
||||
|
||||
futures::executor::block_on(nu_cli::run_script_file(
|
||||
buffer,
|
||||
futures::executor::block_on(nu_cli::run_vec_of_pipelines(
|
||||
pipelines,
|
||||
matches.is_present("stdin"),
|
||||
))?;
|
||||
return Ok(());
|
||||
|
Reference in New Issue
Block a user