Skip to content

Commit

Permalink
Removes "parse()" from XTaskArg (#11)
Browse files Browse the repository at this point in the history
Removes clap parsing from run method, so XTaskArgs can be used in a
composable way.
  • Loading branch information
spirali authored Dec 17, 2024
1 parent 5a49edd commit f7843ed
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion example/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion example/xtask_kompari/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@ version = "0.1.0"
edition = "2021"

[dependencies]
demolib = { path = "../demolib"}
demolib = { path = "../demolib" }
clap = { version = "4.5", features = ["derive"] }
kompari = { path = "../..", features = ["xtask-cli"] }
3 changes: 2 additions & 1 deletion example/xtask_kompari/src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
// Copyright 2024 the Kompari Authors
// SPDX-License-Identifier: Apache-2.0 OR MIT

use clap::Parser;
use kompari::xtask_cli::{XtaskActions, XtaskArgs};
use std::path::Path;
use std::process::Command;
Expand All @@ -26,5 +27,5 @@ fn main() -> kompari::Result<()> {
let current_path = tests_path.join("current");
let snapshots_path = tests_path.join("snapshots");

XtaskArgs::run(&current_path, &snapshots_path, XtaskActionsImpl())
XtaskArgs::parse().run(&current_path, &snapshots_path, XtaskActionsImpl())
}
8 changes: 4 additions & 4 deletions src/xtask_cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@ pub trait XtaskActions {

impl XtaskArgs {
pub fn run(
&self,
current_path: &Path,
snapshots_path: &Path,
actions: impl XtaskActions,
) -> crate::Result<()> {
let args = XtaskArgs::parse();
match args.command {
match &self.command {
XtaskCommand::Report(report_args) => {
create_report(current_path, snapshots_path, &report_args)?;
create_report(current_path, snapshots_path, report_args)?;
}
XtaskCommand::Clean => {
clean_image_dir(current_path)?;
}
XtaskCommand::DeadSnapshots(ds_args) => {
process_dead_snapshots(current_path, snapshots_path, actions, &ds_args)?;
process_dead_snapshots(current_path, snapshots_path, actions, ds_args)?;
}
}
Ok(())
Expand Down

0 comments on commit f7843ed

Please sign in to comment.