forked from extern/nushell
This reverts commit e66bf70589
.
This commit is contained in:
@ -62,11 +62,11 @@ impl ClassifiedBlock {
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
|
||||
pub struct ClassifiedPipeline {
|
||||
pub commands: Pipeline,
|
||||
pub commands: Commands,
|
||||
}
|
||||
|
||||
impl ClassifiedPipeline {
|
||||
pub fn new(commands: Pipeline) -> ClassifiedPipeline {
|
||||
pub fn new(commands: Commands) -> ClassifiedPipeline {
|
||||
ClassifiedPipeline { commands }
|
||||
}
|
||||
}
|
||||
@ -92,14 +92,14 @@ impl ClassifiedCommand {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
|
||||
pub struct Pipeline {
|
||||
pub struct Commands {
|
||||
pub list: Vec<ClassifiedCommand>,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl Pipeline {
|
||||
pub fn new(span: Span) -> Pipeline {
|
||||
Pipeline { list: vec![], span }
|
||||
impl Commands {
|
||||
pub fn new(span: Span) -> Commands {
|
||||
Commands { list: vec![], span }
|
||||
}
|
||||
|
||||
pub fn push(&mut self, command: ClassifiedCommand) {
|
||||
@ -111,34 +111,15 @@ impl Pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
|
||||
pub struct Group {
|
||||
pub pipelines: Vec<Pipeline>,
|
||||
pub span: Span,
|
||||
}
|
||||
impl Group {
|
||||
pub fn new(pipelines: Vec<Pipeline>, span: Span) -> Group {
|
||||
Group { pipelines, span }
|
||||
}
|
||||
|
||||
pub fn push(&mut self, pipeline: Pipeline) {
|
||||
self.pipelines.push(pipeline);
|
||||
}
|
||||
|
||||
pub fn has_it_usage(&self) -> bool {
|
||||
self.pipelines.iter().any(|cc| cc.has_it_usage())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
|
||||
pub struct Block {
|
||||
pub params: Vec<String>,
|
||||
pub block: Vec<Group>,
|
||||
pub block: Vec<Commands>,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl Block {
|
||||
pub fn new(params: Vec<String>, block: Vec<Group>, span: Span) -> Block {
|
||||
pub fn new(params: Vec<String>, block: Vec<Commands>, span: Span) -> Block {
|
||||
let mut output = Block {
|
||||
params,
|
||||
block,
|
||||
@ -149,18 +130,16 @@ impl Block {
|
||||
output
|
||||
}
|
||||
|
||||
pub fn push(&mut self, group: Group) {
|
||||
self.block.push(group);
|
||||
pub fn push(&mut self, commands: Commands) {
|
||||
self.block.push(commands);
|
||||
self.infer_params();
|
||||
}
|
||||
|
||||
pub fn set_redirect(&mut self, external_redirection: ExternalRedirection) {
|
||||
if let Some(group) = self.block.last_mut() {
|
||||
if let Some(pipeline) = group.pipelines.last_mut() {
|
||||
if let Some(command) = pipeline.list.last_mut() {
|
||||
if let ClassifiedCommand::Internal(internal) = command {
|
||||
internal.args.external_redirection = external_redirection;
|
||||
}
|
||||
if let Some(pipeline) = self.block.last_mut() {
|
||||
if let Some(command) = pipeline.list.last_mut() {
|
||||
if let ClassifiedCommand::Internal(internal) = command {
|
||||
internal.args.external_redirection = external_redirection;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user