#cargo-command #command-line-interface #xtask #workspace #bin #subcommand #build

bin+lib cli-xtask

A collection of utility functions and command line interfaces for cargo-xtask

15 releases (8 breaking)

0.8.0 Sep 24, 2023
0.6.1 Dec 3, 2022
0.6.0 Oct 7, 2022

#156 in Programming languages

Download history 314/week @ 2023-12-15 254/week @ 2023-12-22 535/week @ 2023-12-29 336/week @ 2024-01-05 374/week @ 2024-01-12 166/week @ 2024-01-19 421/week @ 2024-01-26 259/week @ 2024-02-02 421/week @ 2024-02-09 341/week @ 2024-02-16 249/week @ 2024-02-23 358/week @ 2024-03-01 269/week @ 2024-03-08 482/week @ 2024-03-15 596/week @ 2024-03-22 191/week @ 2024-03-29

1,577 downloads per month

MIT/Apache

180KB
3K SLoC

cli-xtask

Maintenance: passively-maintained License: MIT OR Apache-2.0 crates.io docs.rs Rust: ^1.70.0 GitHub Actions: CI Codecov

A collection of utility functions and command line interfaces for cargo-xtask.

This crate provides the following utilities:

Usage

First, create an xtask crate following the instructions on the cargo-xtask website.

Then, run the following command to add cli-xtask to the dependencies.

  • For bin crates:

    cargo add -p xtask cli-xtask --features main,bin-crate
    

    If you want to use extra tools such as cargo-sync-rdme and cargo-udeps, add the bin-crate-extra feature.

    cargo add -p xtask cli-xtask --features main,bin-crate,bin-crate-extra
    
  • For lib crates:

    cargo add -p xtask cli-xtask --features main,lib-crate
    

    If you want to use extra tools such as cargo-sync-rdme and cargo-udeps, add the lib-crate-extra feature.

    cargo add -p xtask cli-xtask --features main,lib-crate,lib-crate-extra
    

Finally, edit xtask/src/main.rs as follows

use cli_xtask::{Result, Xtask};

fn main() -> Result<()> {
    <Xtask>::main()
}

Now you can run various workflows with cargo xtask.

Customizing

If you want to remove the subcommands that are not useful for your project, you can remove them by disabling the corresponding cargo features. See the Feature flags section for more information.

If you want to add the subcommands that are not included in this crate, you can add them by creating a new data structure that implements the [clap::Subcommand] and Run. See the documentation of Xtask for more information.

Feature flags

By using the features flags of cli-xtask, you can enable only the features and commands you need. By default, all features are disabled.

The following section contains a list of available features:

CLI features

  • main - Enables [Xtask::main] function and [Xtask::main_with_config] function that are the premade entry point for the CLI.
  • error-handler - Enables functions for error handling in error_handler module.
  • logger - Enables functions for logging in logger module.

Subcommand features

There are two types of features that enable subcommands:

  • Combined features - features that enable several useful subcommands at once, depending on the type of crate
  • Separated features - features that enable each subcommand separately

Combined features

  • bin-crate:- Enables useful subcommands for bin crates.
  • lib-crate - Enables useful subcommands for lib crates.
  • bin-crate-extra - Enables the additional subcommands useful for bin crates.
  • lib-crate-extra - Enables the additional subcommands useful for lib crates.

The {bin,lib}-crate feature requires only the standard Rust tools that can be installed with rustup. The {bin,lib}-crate-extra feature may require third-party tools.

Separated features

The following features require only the standard Rust tools:

The following features require third-party tools:

Other features

  • archive - Enables archive module which provides the functionality to create the archive file for distribution.

Minimum supported Rust version (MSRV)

The minimum supported Rust version is Rust 1.70.0. At least the last 3 versions of stable Rust are supported at any given time.

While a crate is a pre-release status (0.x.x) it may have its MSRV bumped in a patch release. Once a crate has reached 1.x, any MSRV bump will be accompanied by a new minor version.

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

See CONTRIBUTING.md.

Dependencies

~2–15MB
~173K SLoC