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

bin+lib cli-xtask

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

16 releases (9 breaking)

new 0.9.0 Nov 30, 2024
0.8.0 Sep 24, 2023
0.7.1 Sep 23, 2023
0.6.1 Dec 3, 2022
0.6.0 Oct 7, 2022

#191 in Command line utilities

Download history 285/week @ 2024-08-16 495/week @ 2024-08-23 286/week @ 2024-08-30 474/week @ 2024-09-06 194/week @ 2024-09-13 479/week @ 2024-09-20 538/week @ 2024-09-27 292/week @ 2024-10-04 288/week @ 2024-10-11 512/week @ 2024-10-18 275/week @ 2024-10-25 636/week @ 2024-11-01 448/week @ 2024-11-08 239/week @ 2024-11-15 291/week @ 2024-11-22 1056/week @ 2024-11-29

2,090 downloads per month

MIT/Apache

175KB
3K SLoC

cli-xtask

Maintenance: passively-maintained License: MIT OR Apache-2.0 crates.io docs.rs Rust: ^1.78.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.78.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–14MB
~174K SLoC