mirror of
https://github.com/GothenburgBitFactory/taskwarrior.git
synced 2025-06-26 10:54:26 +02:00

* move taskchampion-lib to src/tc/lib, remove the rest * update references to taskchampion * Use a top-level Cargo.toml so everything is consistent * apply comments from ryneeverett
35 lines
1.1 KiB
Rust
35 lines
1.1 KiB
Rust
//! This executable defines the `cargo xtask` subcommands.
|
|
//!
|
|
//! At the moment it is very simple, but if this grows more subcommands then
|
|
//! it will be sensible to use `clap` or another similar library.
|
|
|
|
use std::env;
|
|
use std::fs::File;
|
|
use std::io::Write;
|
|
use std::path::{Path, PathBuf};
|
|
|
|
pub fn main() -> anyhow::Result<()> {
|
|
let manifest_dir = PathBuf::from(env::var("CARGO_MANIFEST_DIR")?);
|
|
let workspace_dir = manifest_dir.parent().unwrap();
|
|
let arguments: Vec<String> = env::args().collect();
|
|
|
|
if arguments.len() < 2 {
|
|
anyhow::bail!("xtask: Valid arguments are: `codegen`");
|
|
}
|
|
|
|
match arguments[1].as_str() {
|
|
"codegen" => codegen(workspace_dir),
|
|
_ => anyhow::bail!("xtask: unknown xtask"),
|
|
}
|
|
}
|
|
|
|
/// `cargo xtask codegen`
|
|
///
|
|
/// This uses ffizz-header to generate `lib/taskchampion.h`.
|
|
fn codegen(workspace_dir: &Path) -> anyhow::Result<()> {
|
|
let lib_crate_dir = workspace_dir.join("src/tc/lib");
|
|
let mut file = File::create(lib_crate_dir.join("taskchampion.h")).unwrap();
|
|
write!(&mut file, "{}", ::taskchampion_lib::generate_header()).unwrap();
|
|
|
|
Ok(())
|
|
}
|