mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 11:05:40 +02:00
@ -44,16 +44,27 @@ impl InternalCommand {
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
|
||||
pub struct ClassifiedPipeline {
|
||||
pub commands: Commands,
|
||||
pub struct ClassifiedBlock {
|
||||
pub block: Block,
|
||||
// this is not a Result to make it crystal clear that these shapes
|
||||
// aren't intended to be used directly with `?`
|
||||
pub failed: Option<ParseError>,
|
||||
}
|
||||
|
||||
impl ClassifiedBlock {
|
||||
pub fn new(block: Block, failed: Option<ParseError>) -> ClassifiedBlock {
|
||||
ClassifiedBlock { block, failed }
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
|
||||
pub struct ClassifiedPipeline {
|
||||
pub commands: Commands,
|
||||
}
|
||||
|
||||
impl ClassifiedPipeline {
|
||||
pub fn new(commands: Commands, failed: Option<ParseError>) -> ClassifiedPipeline {
|
||||
ClassifiedPipeline { commands, failed }
|
||||
pub fn new(commands: Commands) -> ClassifiedPipeline {
|
||||
ClassifiedPipeline { commands }
|
||||
}
|
||||
}
|
||||
|
||||
@ -83,6 +94,25 @@ impl Commands {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, PartialOrd, Eq, Ord, Hash, Serialize, Deserialize)]
|
||||
pub struct Block {
|
||||
pub block: Vec<Commands>,
|
||||
pub span: Span,
|
||||
}
|
||||
|
||||
impl Block {
|
||||
pub fn new(span: Span) -> Block {
|
||||
Block {
|
||||
block: vec![],
|
||||
span,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn push(&mut self, commands: Commands) {
|
||||
self.block.push(commands);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Ord, PartialOrd, Eq, PartialEq, Clone, Hash, Deserialize, Serialize)]
|
||||
pub struct ExternalStringCommand {
|
||||
pub name: Spanned<String>,
|
||||
@ -766,7 +796,7 @@ pub enum Expression {
|
||||
Variable(Variable),
|
||||
Binary(Box<Binary>),
|
||||
Range(Box<Range>),
|
||||
Block(hir::Commands),
|
||||
Block(hir::Block),
|
||||
List(Vec<SpannedExpression>),
|
||||
Path(Box<Path>),
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
use crate::hir::Commands;
|
||||
use crate::hir::Block;
|
||||
use crate::value::Value;
|
||||
use nu_errors::ShellError;
|
||||
use nu_source::{b, DebugDocBuilder, PrettyDebug};
|
||||
@ -22,7 +22,7 @@ pub enum CommandAction {
|
||||
/// Enter the help shell, which allows exploring the help system
|
||||
EnterHelpShell(Value),
|
||||
/// Enter the help shell, which allows exploring the help system
|
||||
AddAlias(String, Vec<String>, Commands),
|
||||
AddAlias(String, Vec<String>, Block),
|
||||
/// Go to the previous shell in the shell ring buffer
|
||||
PreviousShell,
|
||||
/// Go to the next shell in the shell ring buffer
|
||||
|
@ -37,8 +37,8 @@ pub enum UntaggedValue {
|
||||
/// An error value that represents an error that occurred as the values in the pipeline were built
|
||||
Error(ShellError),
|
||||
|
||||
/// A block of Nu code, eg `{ ls | get name }`
|
||||
Block(hir::Commands),
|
||||
/// A block of Nu code, eg `{ ls | get name ; echo "done" }`
|
||||
Block(hir::Block),
|
||||
}
|
||||
|
||||
impl UntaggedValue {
|
||||
|
Reference in New Issue
Block a user