Remove useless intermediary struct

This commit is contained in:
Zykino 2023-01-14 21:32:39 +01:00
parent f6813025a3
commit 448430b749
3 changed files with 62 additions and 54 deletions

31
examples/debian.yml Normal file
View File

@ -0,0 +1,31 @@
systems:
- fetch:
exe: sudo
params:
- apt
- update
current_dir: null
env: {}
compile: null
install:
exe: sudo
params:
- apt
- upgrade
current_dir: null
env: {}
- install:
exe: rustup
params:
- update
current_dir: null
env: {}
- install:
exe: cargo
params:
- install-update
- -a
current_dir: null
env: {}
steps: Install
nice: null

View File

@ -1,35 +1,30 @@
systems: systems:
- fetch: - fetch:
command: exe: sudo
exe: sudo params:
params: - zypper
- zypper - refresh
- refresh current_dir: null
current_dir: null env: {}
env: {}
compile: null compile: null
install: install:
command: exe: sudo
exe: sudo params:
params: - zypper
- zypper - dup
- dup current_dir: null
current_dir: null env: {}
env: {}
- install: - install:
command: exe: rustup
exe: rustup params:
params: - update
- update current_dir: null
current_dir: null env: {}
env: {}
- install: - install:
command: exe: cargo
exe: cargo params:
params: - install-update
- install-update - -a
- -a current_dir: null
current_dir: null env: {}
env: {}
steps: Install steps: Install
nice: null

View File

@ -18,33 +18,18 @@ enum UpdateSteps {
pub struct Updater { pub struct Updater {
systems: Vec<System>, systems: Vec<System>,
steps: UpdateSteps, steps: UpdateSteps,
nice: Option<i32>,
} }
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
pub struct System { pub struct System {
fetch: Option<Fetch>, //name: String,
compile: Option<Compile>, fetch: Option<Cmd>,
install: Install, compile: Option<Cmd>,
install: Cmd,
// deps or rDeps : Tree // deps or rDeps : Tree
// exclusive_with : List // exclusive_with : List
} }
#[derive(Debug, Serialize, Deserialize)]
pub struct Fetch {
command: Cmd,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Compile {
command: Cmd,
}
#[derive(Debug, Serialize, Deserialize)]
pub struct Install {
command: Cmd,
}
#[derive(Debug, Serialize, Deserialize)] #[derive(Debug, Serialize, Deserialize)]
struct Cmd { struct Cmd {
exe: String, exe: String,
@ -58,14 +43,11 @@ impl Updater {
let mut up = Updater { let mut up = Updater {
systems: vec![], systems: vec![],
steps: UpdateSteps::Fetch, steps: UpdateSteps::Fetch,
nice: None,
}; };
up.systems.push(System { up.systems.push(System {
fetch: None, fetch: None,
compile: None, compile: None,
install: Install { install: Cmd::new(),
command: Cmd::new(),
},
}); });
up up
} }
@ -134,20 +116,20 @@ impl Updater {
impl System { impl System {
pub fn fetch(&self) -> Result<()> { pub fn fetch(&self) -> Result<()> {
if let Some(fetch) = &self.fetch { if let Some(fetch) = &self.fetch {
fetch.command.execute()?; fetch.execute()?;
} }
Ok(()) Ok(())
} }
pub fn compile(&self) -> Result<()> { pub fn compile(&self) -> Result<()> {
if let Some(compile) = &self.compile { if let Some(compile) = &self.compile {
compile.command.execute()?; compile.execute()?;
} }
Ok(()) Ok(())
} }
pub fn install(&self) -> Result<()> { pub fn install(&self) -> Result<()> {
self.install.command.execute()?; self.install.execute()?;
Ok(()) Ok(())
} }
} }