Start work on init command
This commit is contained in:
parent
bc4557a9ca
commit
564ea919a5
5 changed files with 46 additions and 3 deletions
2
Cargo.lock
generated
2
Cargo.lock
generated
|
|
@ -784,7 +784,7 @@ checksum = "42ff0bf0c66b8238c6f3b578df37d0b7848e55df8577b3f74f92a69acceeb825"
|
|||
|
||||
[[package]]
|
||||
name = "ublue-rs"
|
||||
version = "0.1.0"
|
||||
version = "0.2.0"
|
||||
dependencies = [
|
||||
"anyhow",
|
||||
"clap",
|
||||
|
|
|
|||
|
|
@ -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"
|
||||
|
|
|
|||
|
|
@ -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!();
|
||||
|
|
|
|||
23
src/lib.rs
23
src/lib.rs
|
|
@ -38,6 +38,13 @@ pub enum CommandArgs {
|
|||
output: Option<PathBuf>,
|
||||
},
|
||||
|
||||
/// Initialize a new Ublue Starting Point repo
|
||||
Init {
|
||||
/// The directory to extract the files into. Defaults to the current directory
|
||||
#[arg()]
|
||||
dir: Option<PathBuf>,
|
||||
},
|
||||
|
||||
/// Build an image from a Containerfile
|
||||
Build {
|
||||
#[arg()]
|
||||
|
|
@ -107,3 +114,19 @@ pub fn setup_tera(recipe: String, containerfile: Option<PathBuf>) -> 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/");
|
||||
}
|
||||
|
|
|
|||
10
templates/init/gitlab-ci.yml
Normal file
10
templates/init/gitlab-ci.yml
Normal file
|
|
@ -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
|
||||
Loading…
Add table
Add a link
Reference in a new issue