#[non_exhaustive]pub enum Stmt {
Show 17 variants
Assignment(Assignment),
Command(Command),
Pipeline(Pipeline),
If(IfStmt),
For(ForLoop),
While(WhileLoop),
Case(CaseStmt),
Break(Option<usize>),
Continue(Option<usize>),
Return(Option<Box<Expr>>),
Exit(Option<Box<Expr>>),
ToolDef(ToolDef),
Test(TestExpr),
AndChain {
left: Box<Stmt>,
right: Box<Stmt>,
},
OrChain {
left: Box<Stmt>,
right: Box<Stmt>,
},
EnvScoped {
assignments: Vec<Assignment>,
body: Box<Stmt>,
},
Empty,
}Expand description
A single statement in kaish.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Assignment(Assignment)
Variable assignment: NAME=value or local NAME = value
Command(Command)
Simple command: tool arg1 arg2
Pipeline(Pipeline)
Pipeline: a | b | c
If(IfStmt)
Conditional: if cond; then ...; fi
For(ForLoop)
Loop: for X in items; do ...; done
While(WhileLoop)
While loop: while cond; do ...; done
Case(CaseStmt)
Case statement: case expr in pattern) ... ;; esac
Break(Option<usize>)
Break out of loop: break or break N
Continue(Option<usize>)
Continue to next iteration: continue or continue N
Return(Option<Box<Expr>>)
Return from tool: return or return expr
Exit(Option<Box<Expr>>)
Exit the script: exit or exit code
ToolDef(ToolDef)
Tool definition: tool name(params) { body }
Test(TestExpr)
Test expression: [[ -f path ]] or [[ $X == "value" ]]
AndChain
Statement chain with &&: run right only if left succeeds
OrChain
Statement chain with ||: run right only if left fails
EnvScoped
Inline env prefix: NAME=value... command. The assignments are exported
for the duration of body only (bash-style command-scoped environment)
and do not persist after it — distinct from a plain Assignment, which
is persistent. body is always a command or pipeline.
Empty
Empty statement (newline or semicolon only)
Implementations§
Trait Implementations§
impl StructuralPartialEq for Stmt
Auto Trait Implementations§
impl Freeze for Stmt
impl RefUnwindSafe for Stmt
impl Send for Stmt
impl Sync for Stmt
impl Unpin for Stmt
impl UnsafeUnpin for Stmt
impl UnwindSafe for Stmt
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
impl<T> OrderedSeq<'_, T> for Twhere
T: Clone,
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
impl<'p, T> Seq<'p, T> for Twhere
T: Clone,
Source§impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
impl<T, S> SpanWrap<S> for Twhere
S: WrappingSpan<T>,
Source§fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
fn with_span(self, span: S) -> <S as WrappingSpan<Self>>::Spanned
WrappingSpan::make_wrapped to wrap an AST node in a span.