Tracel Xtask
[![Discord](https://img.shields.io/discord/1038839012602941528.svg?color=7289da&&logo=discord)](https://discord.gg/uPEBbYYDB6)
[![Current Crates.io Version](https://img.shields.io/crates/v/tracel-xtask)](https://crates.io/crates/tracel-xtask)
[![Minimum Supported Rust Version](https://img.shields.io/crates/msrv/tracel-xtask)](https://crates.io/crates/tracel-xtask)
[![Test Status](https://github.com/tracel-ai/xtask/actions/workflows/ci.yml/badge.svg)](https://github.com/tracel-ai/xtask/actions/workflows/ci.yml)
![license](https://shields.io/badge/license-MIT%2FApache--2.0-blue)
---
A collection of easy-to-use and extensible commands to be used in your [xtask CLI][1] based on [clap][2].
We rely on these commands in each of our Tracel repositories. By centralizing our redundant commands we save a big amount
of code duplication, boilerplate and considerably lower their maintenance cost. This also provides a unified interface across
all of our repositories.
These commands are not specific to Tracel repositories and they should be pretty much usable in any Rust repositories with
a cargo workspace as well as other repositories where Rust is not necessarily the only language. The commands can be easily
extended using handy proc macros and by following some patterns described in this README.
## Getting Started
### Setting Up a Cargo Workspace with an xtask binary crate
1. **Create a new Cargo workspace:**
```bash
cargo new my_workspace --vcs none
cd my_workspace
```
2. **Create the `xtask` binary crate:**
```bash
cargo new xtask --bin --vcs none
```
3. **Configure the workspace:**
Edit the `Cargo.toml` file in the root of the workspace to include the following:
```toml
[workspace]
members = ["xtask"]
```
4. **Add the `tracel-xtask` dependency:**
In the `xtask/Cargo.toml` file, add the following under `[dependencies]`:
```toml
[dependencies]
tracel-xtask = "~1.0"
```
5. **Build the workspace:**
```bash
cargo build
```
Your workspace is now set up with a `xtask` binary crate that depends on `tracel-xtask` version 1.0.x.
### Bootstrap main.rs
1. In the `main.rs` file of the newly created `xtask` crate, import the `tracel_xtask` prelude module and then declare
a `Command` enum. Select the base commands you want to use by adding the `macros::base_commands` attribute:
```rust
use tracel_xtask::prelude::*;
#[macros::base_commands(
Bump,
Check,
Fix
Test,
)]
pub enum Command {}
```
2. Update the `main` function to initialize the xtask parser and dispatch the base commands:
```rust
fn main() -> anyhow::Result<()> {
let args = init_xtask::