Skip to content

Commit

Permalink
Merge pull request #183 from webern/clean
Browse files Browse the repository at this point in the history
twoilter: add build clean command
  • Loading branch information
webern authored Apr 4, 2024
2 parents 344092e + 09d8e5a commit b8eb518
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
1 change: 0 additions & 1 deletion tests/projects/local-kit/Release.toml

This file was deleted.

1 change: 1 addition & 0 deletions tests/projects/local-kit/Twoliter.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
schema-version = 1
release-version = "1.0.0"

[sdk]
registry = "twoliter.alpha"
Expand Down
5 changes: 4 additions & 1 deletion twoliter/src/cmd/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use super::build_clean::BuildClean;
use crate::cargo_make::CargoMake;
use crate::common::fs;
use crate::docker::DockerContainer;
Expand All @@ -11,13 +12,15 @@ use tempfile::TempDir;

#[derive(Debug, Parser)]
pub(crate) enum BuildCommand {
Clean(BuildClean),
Variant(BuildVariant),
}

impl BuildCommand {
pub(crate) async fn run(self) -> Result<()> {
match self {
BuildCommand::Variant(build_variant) => build_variant.run().await,
BuildCommand::Clean(command) => command.run().await,
BuildCommand::Variant(command) => command.run().await,
}
}
}
Expand Down
31 changes: 31 additions & 0 deletions twoliter/src/cmd/build_clean.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
use crate::cargo_make::CargoMake;
use crate::project;
use crate::tools;
use anyhow::Result;
use clap::Parser;
use std::path::PathBuf;

#[derive(Debug, Parser)]
pub(crate) struct BuildClean {
/// Path to Twoliter.toml. Will search for Twoliter.toml when absent.
#[clap(long = "project-path")]
project_path: Option<PathBuf>,
}

impl BuildClean {
pub(super) async fn run(&self) -> Result<()> {
let project = project::load_or_find_project(self.project_path.clone()).await?;
let toolsdir = project.project_dir().join("build/tools");
tools::install_tools(&toolsdir).await?;
let makefile_path = toolsdir.join("Makefile.toml");

CargoMake::new(&project)?
.env("TWOLITER_TOOLS_DIR", toolsdir.display().to_string())
.makefile(makefile_path)
.project_dir(project.project_dir())
.exec("clean")
.await?;

Ok(())
}
}
1 change: 1 addition & 0 deletions twoliter/src/cmd/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
mod build;
mod build_clean;
mod debug;
mod make;

Expand Down

0 comments on commit b8eb518

Please sign in to comment.