From 448430b74954493fb6d9118a7a25d5ddc0c99740 Mon Sep 17 00:00:00 2001 From: Zykino Date: Sat, 14 Jan 2023 21:32:39 +0100 Subject: [PATCH] Remove useless intermediary struct --- examples/debian.yml | 31 ++++++++++++++++++++++++++ examples/openSUSE.yml | 51 +++++++++++++++++++------------------------ src/command.rs | 34 +++++++---------------------- 3 files changed, 62 insertions(+), 54 deletions(-) create mode 100644 examples/debian.yml diff --git a/examples/debian.yml b/examples/debian.yml new file mode 100644 index 0000000..b01ba9d --- /dev/null +++ b/examples/debian.yml @@ -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 diff --git a/examples/openSUSE.yml b/examples/openSUSE.yml index a3c8864..f921950 100644 --- a/examples/openSUSE.yml +++ b/examples/openSUSE.yml @@ -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 diff --git a/src/command.rs b/src/command.rs index b89828e..8d58b8f 100644 --- a/src/command.rs +++ b/src/command.rs @@ -18,33 +18,18 @@ enum UpdateSteps { pub struct Updater { systems: Vec, steps: UpdateSteps, - nice: Option, } #[derive(Debug, Serialize, Deserialize)] pub struct System { - fetch: Option, - compile: Option, - install: Install, + //name: String, + fetch: Option, + compile: Option, + 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(()) } }