Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

twoilter: add build clean command #183

Merged
merged 1 commit into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading