nanite_docker/instruction/entrypoint.rs
1use alloc::string::String;
2use alloc::vec::Vec;
3use core::fmt::{Display, Formatter};
4
5/// Represents an `ENTRYPOINT` instruction.
6/// ```rust
7/// use nanite_docker::Entrypoint;
8///
9/// let entrypoint = Entrypoint {
10/// argv: vec![
11/// "arg1".to_string(),
12/// "arg2".to_string(),
13/// ],
14/// };
15/// let entrypoint_built = format!("{entrypoint}");
16/// assert_eq!(entrypoint_built, r#"ENTRYPOINT ["arg1", "arg2"]"#);
17/// ```
18#[derive(Clone, Debug)]
19pub struct Entrypoint {
20 pub argv: Vec<String>,
21}
22impl Display for Entrypoint {
23 fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
24 write!(f, "ENTRYPOINT [")?;
25
26 for (i, arg) in self.argv.iter().enumerate() {
27 if i != 0 {
28 write!(f, ", ")?;
29 }
30 write!(f, r#""{arg}""#)?;
31 }
32
33 write!(f, "]")?;
34
35 Ok(())
36 }
37}