compose_lens/model/command.rs
1//! Service command forms.
2
3use super::Located;
4use crate::source::SourceSpan;
5
6/// A Compose service command with null, scalar, and list forms retained.
7#[derive(Debug, Clone, PartialEq, Eq)]
8pub enum Command {
9 /// Explicit null: use the command declared by the image.
10 Null(SourceSpan),
11 /// Scalar syntax, including an explicitly empty string.
12 String(Located<String>),
13 /// List syntax, including an explicitly empty list.
14 List {
15 /// The complete sequence span.
16 span: SourceSpan,
17 /// Command arguments in authored order.
18 values: Vec<Located<String>>,
19 },
20}
21
22impl Command {
23 /// Returns the complete command value span.
24 #[must_use]
25 pub const fn span(&self) -> SourceSpan {
26 match self {
27 Self::Null(span) | Self::List { span, .. } => *span,
28 Self::String(value) => value.span(),
29 }
30 }
31}