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:
- fetch:
command:
exe: sudo
params:
- zypper
- refresh
current_dir: null
env: {}
exe: sudo
params:
- zypper
- refresh
current_dir: null
env: {}
compile: null
install:
command:
exe: sudo
params:
- zypper
- dup
current_dir: null
env: {}
exe: sudo
params:
- zypper
- dup
current_dir: null
env: {}
- install:
command:
exe: rustup
params:
- update
current_dir: null
env: {}
exe: rustup
params:
- update
current_dir: null
env: {}
- install:
command:
exe: cargo
params:
- install-update
- -a
current_dir: null
env: {}
exe: cargo
params:
- install-update
- -a
current_dir: null
env: {}
steps: Install
nice: null

View File

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