From d1d29ae710c2fd89609738a8d5ac21401ba29d34 Mon Sep 17 00:00:00 2001 From: Julian Labatut Date: Thu, 7 Apr 2022 21:58:10 +0200 Subject: [PATCH] quark: Implement `build` subcommand Signed-off-by: Julian Labatut --- README.md | 22 +++++++++++++++++++++- src/cli/build.rs | 30 ++++++++++++++++++++++++++++++ src/cli/mod.rs | 5 +++++ 3 files changed, 56 insertions(+), 1 deletion(-) create mode 100644 src/cli/build.rs diff --git a/README.md b/README.md index 8f9a918..59546fa 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,23 @@ -# Lumper +# Quark + +## Build a quardle + +Building a `quardle` with the container image bundled into the initramfs image : + +```bash +quark build --image --offline --quardle +``` + +Building a `quardle` with the container image to be pulled from within the guest: + +```bash +quark build --image --quardle +``` + +## Run a quardle + +```bash +quark run --quardle --output +``` diff --git a/src/cli/build.rs b/src/cli/build.rs new file mode 100644 index 0000000..a9b669f --- /dev/null +++ b/src/cli/build.rs @@ -0,0 +1,30 @@ +use clap::Args; + +use super::{Handler, Result}; + +/// Arguments for `BuildCommand` +/// +/// Usage : +/// `quark build --image [--offline] --quardle ` +#[derive(Debug, Args)] +pub struct BuildCommand { + /// The name of the generated quardle, with the suffix `.qrk` + #[clap(short, long)] + quardle: String, + + /// The container image url to use + #[clap(short, long)] + image: String, + + /// Indicates wether or not the container image is bundled into the initramfs image + #[clap(short, long)] + offline: bool +} + +/// Method that will be called when the command is executed. +impl Handler for BuildCommand { + fn handler(&self) -> Result<()> { + // TODO + Ok(()) + } +} diff --git a/src/cli/mod.rs b/src/cli/mod.rs index 4fcc454..4a89d15 100644 --- a/src/cli/mod.rs +++ b/src/cli/mod.rs @@ -1,6 +1,8 @@ mod run; +mod build; use crate::cli::run::RunCommand; +use crate::cli::build::BuildCommand; use clap::{Parser, Subcommand}; #[derive(Debug)] @@ -24,6 +26,7 @@ impl Cli { /// Return the command used in the cli. pub fn command(self) -> Box { match self.command { + Command::Build(cmd) => Box::new(cmd), Command::Run(cmd) => Box::new(cmd), } } @@ -41,6 +44,8 @@ impl Cli { /// List(ListCommand) #[derive(Subcommand, Debug)] pub enum Command { + /// Build a quardle + Build(BuildCommand), /// Run a quardle Run(RunCommand), }