Skip to content

Commit

Permalink
photoshoot: binarize
Browse files Browse the repository at this point in the history
  • Loading branch information
BrettMayson committed Jan 16, 2025
1 parent 2f45d9c commit 1f69146
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
31 changes: 23 additions & 8 deletions bin/src/commands/dev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ pub struct Command {
#[clap(flatten)]
pub(crate) dev: DevArgs,

#[clap(flatten)]
pub(crate) binarize: BinarizeArgs,

#[clap(flatten)]
pub(crate) just: JustArgs,

Expand All @@ -47,12 +50,6 @@ pub struct Command {
#[derive(clap::Args)]
#[allow(clippy::module_name_repetitions)]
pub struct DevArgs {
#[arg(long, short, action = clap::ArgAction::SetTrue, verbatim_doc_comment)]
/// Use BI's binarize on supported files
///
/// By default, `hemtt dev` will not binarize any files, but rather pack them as-is.
/// Binarization is often not needed for development.
pub(crate) binarize: bool,
#[arg(long, short, action = clap::ArgAction::Append, verbatim_doc_comment)]
/// Include an optional addon folder
///
Expand All @@ -72,12 +69,29 @@ pub struct DevArgs {
pub(crate) no_rap: bool,
}

#[derive(Clone, clap::Args)]
pub struct BinarizeArgs {
#[arg(long, short, action = clap::ArgAction::SetTrue, verbatim_doc_comment)]
/// Use BI's binarize on supported files
///
/// By default, `hemtt dev` will not binarize any files, but rather pack them as-is.
/// Binarization is often not needed for development.
pub(crate) binarize: bool,
}

/// Execute the dev command
///
/// # Errors
/// [`Error`] depending on the modules
pub fn execute(cmd: &Command, launch_optionals: &[String]) -> Result<(Report, Context), Error> {
let mut executor = context(&cmd.dev, &cmd.just, launch_optionals, false, true)?;
let mut executor = context(
&cmd.dev,
&cmd.binarize,
&cmd.just,
launch_optionals,
false,
true,
)?;
executor.run().map(|r| (r, executor.into_ctx()))
}

Expand All @@ -87,6 +101,7 @@ pub fn execute(cmd: &Command, launch_optionals: &[String]) -> Result<(Report, Co
/// [`Error`] depending on the modules
pub fn context(
dev: &DevArgs,
binarize: &BinarizeArgs,
just: &JustArgs,
launch_optionals: &[String],
force_binarize: bool,
Expand Down Expand Up @@ -153,7 +168,7 @@ pub fn context(
}
executor.add_module(Box::<Files>::default());
executor.add_module(Box::<FilePatching>::default());
if force_binarize || dev.binarize {
if force_binarize || binarize.binarize {
executor.add_module(Box::<Binarize>::default());
}

Expand Down
4 changes: 4 additions & 0 deletions bin/src/commands/launch/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ pub struct Command {
#[clap(flatten)]
dev: super::dev::DevArgs,

#[clap(flatten)]
binarize: super::dev::BinarizeArgs,

#[clap(flatten)]
just: super::JustArgs,

Expand Down Expand Up @@ -287,6 +290,7 @@ pub fn execute(cmd: &Command) -> Result<Report, Error> {
} else {
let mut executor = super::dev::context(
&cmd.dev,
&cmd.binarize,
&cmd.just,
launch.optionals(),
launch.binarize(),
Expand Down
5 changes: 4 additions & 1 deletion bin/src/commands/photoshoot/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ pub struct Command {
/// - `.hemtt/launch.toml`
config: Option<Vec<String>>,

#[clap(flatten)]
binarize: dev::BinarizeArgs,

#[clap(flatten)]
global: crate::GlobalArgs,
}
Expand Down Expand Up @@ -100,9 +103,9 @@ pub fn execute(cmd: &Command) -> Result<Report, Error> {
dev: dev::DevArgs {
optional: Vec::new(),
all_optionals: true,
binarize: false,
no_rap: false,
},
binarize: cmd.binarize.clone(),
just: JustArgs { just: Vec::new() },
},
launch.optionals(),
Expand Down

0 comments on commit 1f69146

Please sign in to comment.