-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor and begin transition to
async
- Loading branch information
Showing
48 changed files
with
1,484 additions
and
1,297 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
//! Definition of the command line arguments. | ||
use std::path::PathBuf; | ||
|
||
use clap::Parser; | ||
|
||
use crate::config::projects::Architecture; | ||
|
||
/// Command line arguments. | ||
#[derive(Debug, Parser)] | ||
#[command(author, about = None, long_about = None)] | ||
pub struct Args { | ||
/// Path to the `rugix-bakery.toml` configuration file. | ||
#[clap(long)] | ||
pub config: Option<PathBuf>, | ||
/// The command to execute. | ||
#[clap(subcommand)] | ||
pub cmd: Command, | ||
} | ||
|
||
/// Commands of the CLI. | ||
#[derive(Debug, Parser)] | ||
pub enum Command { | ||
/// Bake an image or a layer. | ||
#[clap(subcommand)] | ||
Bake(BakeCommand), | ||
/// Run integration tests. | ||
Test(TestCommand), | ||
/// List images, recipes, and layers. | ||
#[clap(subcommand)] | ||
List(ListCommand), | ||
/// Pull in external repositories. | ||
Pull, | ||
/// Initialize the project from a template. | ||
Init(InitCommand), | ||
/// Spawn a shell in the Rugpi Bakery Docker container. | ||
Shell, | ||
} | ||
|
||
/// The `list` command. | ||
#[derive(Debug, Parser)] | ||
pub enum ListCommand { | ||
/// List available images. | ||
Images, | ||
} | ||
|
||
/// The `bake` command. | ||
#[derive(Debug, Parser)] | ||
pub enum BakeCommand { | ||
/// Bake an image. | ||
Image { | ||
/// The name of the image to bake. | ||
image: String, | ||
/// The output path of the resulting image. | ||
output: Option<PathBuf>, | ||
}, | ||
/// Bake a layer. | ||
Layer { | ||
/// The architecture to bake the layer for. | ||
#[clap(long)] | ||
arch: Architecture, | ||
/// The name of the layer to bake. | ||
layer: String, | ||
}, | ||
} | ||
|
||
/// The `test` command. | ||
#[derive(Debug, Parser)] | ||
pub struct TestCommand { | ||
pub workflows: Vec<String>, | ||
} | ||
|
||
/// The `bake` command. | ||
#[derive(Debug, Parser)] | ||
pub enum InternalCommand { | ||
MakeImage { | ||
config: PathBuf, | ||
source: PathBuf, | ||
image: PathBuf, | ||
}, | ||
} | ||
|
||
/// The `init` command. | ||
#[derive(Debug, Parser)] | ||
pub struct InitCommand { | ||
/// Template to use. | ||
pub template: Option<String>, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
pub mod run_bake; | ||
pub mod run_init; | ||
pub mod run_list; | ||
pub mod run_pull; | ||
pub mod run_shell; | ||
pub mod run_test; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//! The `bake` command. | ||
use std::path::Path; | ||
|
||
use crate::cli::{args, load_project}; | ||
use crate::oven::LayerBakery; | ||
use crate::{oven, BakeryResult}; | ||
|
||
/// Run the `bake` command. | ||
pub async fn run(args: &args::Args, cmd: &args::BakeCommand) -> BakeryResult<()> { | ||
let project = load_project(args).await?; | ||
match cmd { | ||
args::BakeCommand::Image { image, output } => { | ||
let output = output | ||
.clone() | ||
.unwrap_or_else(|| Path::new("build/images").join(image).with_extension("img")); | ||
oven::bake_image(&project, image, &output).await?; | ||
} | ||
args::BakeCommand::Layer { layer, arch } => { | ||
LayerBakery::new(&project, *arch).bake_root(layer).await?; | ||
} | ||
} | ||
Ok(()) | ||
} |
Oops, something went wrong.