diff --git a/Cargo.lock b/Cargo.lock index 994dc04..f24d737 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -784,7 +784,7 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825" [[package]] name = "ublue-rs" -version = "0.1.0" +version = "0.2.0" dependencies = [ "anyhow", "clap", diff --git a/Cargo.toml b/Cargo.toml index f7d347d..16462bd 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ublue-rs" -version = "0.1.0" +version = "0.2.0" edition = "2021" description = "A CLI tool built for creating Containerfile templates based on the Ublue Community Project" repository = "https://gitlab.com/wunker-bunker/ublue-cli" diff --git a/src/bin/ublue.rs b/src/bin/ublue.rs index fbd1e41..be2963d 100644 --- a/src/bin/ublue.rs +++ b/src/bin/ublue.rs @@ -1,6 +1,8 @@ +use std::path::PathBuf; + use anyhow::Result; use clap::Parser; -use ublue_rs::{setup_tera, CommandArgs, UblueArgs}; +use ublue_rs::{initialize_directory, setup_tera, CommandArgs, UblueArgs}; fn main() -> Result<()> { let args = UblueArgs::parse(); @@ -19,6 +21,14 @@ fn main() -> Result<()> { println!("{output_str}"); } } + CommandArgs::Init { dir } => { + let base_dir = match dir { + Some(dir) => dir, + None => PathBuf::from("./"), + }; + + initialize_directory(base_dir); + } CommandArgs::Build { containerfile: _ } => { println!("Not yet implemented!"); todo!(); diff --git a/src/lib.rs b/src/lib.rs index 2f6ca00..e693a18 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,6 +38,13 @@ pub enum CommandArgs { output: Option, }, + /// Initialize a new Ublue Starting Point repo + Init { + /// The directory to extract the files into. Defaults to the current directory + #[arg()] + dir: Option, + }, + /// Build an image from a Containerfile Build { #[arg()] @@ -107,3 +114,19 @@ pub fn setup_tera(recipe: String, containerfile: Option) -> Result<(Ter Ok((tera, context)) } + +pub fn initialize_directory(base_dir: PathBuf) { + let recipe_path = base_dir.join("recipe.yml"); + + let gitlab_ci_path = base_dir.join(".gitlab-ci.yml"); + + let readme_path = base_dir.join("README.md"); + + let license_path = base_dir.join("LICENSE"); + + let scripts_dir = base_dir.join("scripts/"); + + let pre_scripts_dir = scripts_dir.join("pre/"); + + let post_scripts_dir = scripts_dir.join("post/"); +} diff --git a/templates/init/gitlab-ci.yml b/templates/init/gitlab-ci.yml new file mode 100644 index 0000000..330a2dc --- /dev/null +++ b/templates/init/gitlab-ci.yml @@ -0,0 +1,10 @@ +include: + - project: "wunker-bunker/ci-pipelines" + file: "/ublue-build.yml" + +.recipe-matrix: + parallel: + matrix: + # As you create more recipes to build, add them below + - RECIPE: + - recipe.yml