mirror of
https://github.com/nushell/nushell
synced 2025-01-01 15:58:55 +00:00
Add pipelines
This commit is contained in:
parent
c03f700662
commit
0b8352049c
1 changed files with 24 additions and 7 deletions
|
@ -279,7 +279,9 @@ pub enum Statement {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct Pipeline {}
|
pub struct Pipeline {
|
||||||
|
pub expressions: Vec<Expression>,
|
||||||
|
}
|
||||||
|
|
||||||
impl Default for Pipeline {
|
impl Default for Pipeline {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
|
@ -289,7 +291,9 @@ impl Default for Pipeline {
|
||||||
|
|
||||||
impl Pipeline {
|
impl Pipeline {
|
||||||
pub fn new() -> Self {
|
pub fn new() -> Self {
|
||||||
Self {}
|
Self {
|
||||||
|
expressions: vec![],
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +375,7 @@ impl ParserWorkingSet {
|
||||||
let arg_span = spans[*spans_idx];
|
let arg_span = spans[*spans_idx];
|
||||||
let arg_contents = self.get_span_contents(arg_span);
|
let arg_contents = self.get_span_contents(arg_span);
|
||||||
|
|
||||||
if arg_contents.starts_with(&[b'-', b'-']) {
|
if arg_contents.starts_with(b"--") {
|
||||||
// FIXME: only use the first you find
|
// FIXME: only use the first you find
|
||||||
let split: Vec<_> = arg_contents.split(|x| *x == b'=').collect();
|
let split: Vec<_> = arg_contents.split(|x| *x == b'=').collect();
|
||||||
let long_name = String::from_utf8(split[0].into());
|
let long_name = String::from_utf8(split[0].into());
|
||||||
|
@ -428,7 +432,7 @@ impl ParserWorkingSet {
|
||||||
|
|
||||||
let arg_contents = self.get_span_contents(arg_span);
|
let arg_contents = self.get_span_contents(arg_span);
|
||||||
|
|
||||||
if arg_contents.starts_with(&[b'-']) && arg_contents.len() > 1 {
|
if arg_contents.starts_with(b"-") && arg_contents.len() > 1 {
|
||||||
let short_flags = &arg_contents[1..];
|
let short_flags = &arg_contents[1..];
|
||||||
let mut found_short_flags = vec![];
|
let mut found_short_flags = vec![];
|
||||||
let mut unmatched_short_flags = vec![];
|
let mut unmatched_short_flags = vec![];
|
||||||
|
@ -1779,11 +1783,24 @@ impl ParserWorkingSet {
|
||||||
let mut block = Block::new();
|
let mut block = Block::new();
|
||||||
|
|
||||||
for pipeline in &lite_block.block {
|
for pipeline in &lite_block.block {
|
||||||
|
if pipeline.commands.len() > 1 {
|
||||||
|
let mut output = vec![];
|
||||||
|
for command in &pipeline.commands {
|
||||||
|
let (expr, err) = self.parse_expression(&command.parts);
|
||||||
|
error = error.or(err);
|
||||||
|
|
||||||
|
output.push(expr);
|
||||||
|
}
|
||||||
|
block.stmts.push(Statement::Pipeline(Pipeline {
|
||||||
|
expressions: output,
|
||||||
|
}));
|
||||||
|
} else {
|
||||||
let (stmt, err) = self.parse_statement(&pipeline.commands[0].parts);
|
let (stmt, err) = self.parse_statement(&pipeline.commands[0].parts);
|
||||||
error = error.or(err);
|
error = error.or(err);
|
||||||
|
|
||||||
block.stmts.push(stmt);
|
block.stmts.push(stmt);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
self.exit_scope();
|
self.exit_scope();
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue