Crate cargo_rx

source ·
Expand description

githubcrates-iodocs-rs

cargo-rx is a simple, modern Runner for Examples in a Cargo project.

A fuzzy finder tool which extends Cargo to allow you to easily search and run examples from the command line.

This crate provides a single executable: rx.


Demo

rx demo

Basically anywhere you would use cargo run --example in a Rust project, try rx instead.

Install

Ensure that you have a fairly recent version of rust/cargo installed. Then, run:

$ cargo install cargo-rx

Compiler support: requires rustc 1.58+

Windows

Note that on a Windows environment, you will also need to have fzf installed and available in your $PATH variable.

An easy way to install fzf is via Chocolatey:

choco install fzf

There is currently a feature request open on skim which proposes adding support for Windows, but this has not been currently implemented yet – thus, the fzf tool serves as a stand-in alternative for now.

Usage

Once in a Cargo project with an examples/ folder, run:

$ rx

If you want to run a specific example, you can alternatively do that as well:

$ rx my_example -- --my-arg "argument to pass in to example"

Examples

You can check out sample usage of this crate in the examples/ folder in the project repo on GitHub.

Readme Docs

You can find the crate’s readme documentation on the crates.io page, or alternatively in the README.md file on the GitHub project repo.

Structs

  • A simple, modern Example Runner - and fuzzy finder - for Cargo projects.
  • Represents an example file in a Cargo project.
  • Represents an example file item
  • The details on the last run example.
  • Represents path info on a Cargo project.
  • Config which contains replay details on the most recent run example.

Enums

Constants

  • Base constants Project binary command name
  • Commands The cargo command
  • Filenames Name of the Cargo.toml file in Cargo projects
  • The directory which contains examples for Cargo projects
  • The fzf (fuzzy finder) command
  • Name of the main.rs file in Cargo projects
  • Newline character as bytes
  • Rust file extension
  • Name of the settings.toml file for local project cache
  • Space character as bytes

Traits

Functions

Type Definitions

  • Represents any error type.
  • A simple type alias so as to DRY.