Giter Site home page Giter Site logo

loipesmas / cargo-select Goto Github PK

View Code? Open in Web Editor NEW
16.0 1.0 1.0 88 KB

Cargo subcommand to easily run targets/examples

License: GNU General Public License v2.0

Rust 100.00%
rust cargo cargo-plugin cargo-subcommand developer-tools fuzzy fuzzy-matching fuzzy-search fzf rust-lang tui tui-rs

cargo-select's Introduction

cargo-select

Cargo subcommand to easily run targets/examples/tests

Fuzzy match against targets, examples or tests in current rust project. asciicast

cargo-select 0.2.0
LoipesMas
Fuzzy-match targets/examples

USAGE:
    cargo select [OPTIONS] [ARGS]

ARGS:
    <CARGO_COMMAND>    Cargo command to run with selected target (e.g. "run").
    <PATTERN>          Pattern to fuzzy-match targets with. Omit for interactive mode.
    <CARGO_ARGS>...    Additional arguments to pass to cargo.

OPTIONS:
    -h, --help       Print help information
        --no-skip    Run all tests that match selected test (i.e. dont skip names that are
                     supersets)(tests only)
    -V, --version    Print version information

cargo select run is special-cased to cargo run with --package NAME or --example NAME.

cargo select test is special-cased to match against test names (deduced from source files) and run them with cargo test.
Alternatives:

  • You could just do cargo test NAME, but it doesn't let you find tests by name and doesnt work well with workspaces
  • You could do a command similar to cargo test -- --list | fzf | sed "s/: .*//" | xargs cargo test -- --exact, but it requires compiling the tests which can take a lot of time and disk space on some projects (especially ones with a few workspaces). And it still has some limitations.

Installation

From crates.io

cargo install cargo-select

From source

git clone https://github.com/LoipesMas/cargo-select.git
cd cargo-select
cargo install --path .

cargo-select's People

Contributors

loipesmas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

simrit1

cargo-select's Issues

Add test selection

I wish we could fuzzy-select a test to run. I don't know if it's feasible, because the only way (or at least the only way that I know about) to get the list of tests is to run cargo test -- --list which compiles the whole project, which is not optimal.
If you have any ideas or want to try to tackle this, feel free to tell me.
(We could parse every .rs file looking for #[test]s, but I want to believe that there is a better way)

Fix `carg_args`

cargo_args argument is supposed to be working just like cargo does with arguments after --, but I haven't managed to achieve that with clap's derives. Maybe I missed something or maybe we need to use builder api instead.

// TODO: make it a "last" argument, i.e. after "--"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.