Projects STRLCPY jscythe Commits c51d0803
🤬
  • ■ ■ ■ ■ ■
    src/main.rs
    skipped 166 lines
    167 167   std::process::exit(1);
    168 168   }
    169 169   };
     170 + 
    170 171   println!("\navailable execution domains:");
    171 172   for domain in domains {
    172 173   println!("* {}", domain.domain);
    173 174   for command in domain.commands {
    174  - println!(" .{}", command.name);
     175 + println!(" {}", command.display());
    175 176   }
    176 177   }
    177 178   std::process::exit(0);
    skipped 57 lines
  • ■ ■ ■ ■ ■ ■
    src/protocol.rs
    skipped 8 lines
    9 9  }
    10 10   
    11 11  #[derive(Deserialize, Debug)]
     12 +pub(crate) struct DomainCommandParam {
     13 + pub name: String,
     14 +}
     15 + 
     16 +#[derive(Deserialize, Debug)]
    12 17  pub(crate) struct DomainCommand {
    13 18   pub name: String,
     19 + pub parameters: Option<Vec<DomainCommandParam>>,
     20 +}
     21 + 
     22 +impl DomainCommand {
     23 + pub fn display(&self) -> String {
     24 + let args = match &self.parameters {
     25 + Some(params) => params
     26 + .iter()
     27 + .map(|p| p.name.to_owned())
     28 + .collect::<Vec<String>>()
     29 + .join(", "),
     30 + None => "".to_owned(),
     31 + };
     32 + format!(".{}({})", self.name, args)
     33 + }
    14 34  }
    15 35   
    16 36  #[derive(Deserialize, Debug)]
    skipped 84 lines
Please wait...
Page is in error, reload to recover