GitXplorerGitXplorer
c

cargo-open

public
22 stars
5 forks
10 issues

Commits

List of commits on branch master.
Verified
f50766a022c9ccf117d39f9cee8d37e8a5198ca0

Bump the version to 0.4.0

ccarols10cents committed 5 years ago
Verified
a95a9565bf3569a7de3ebf8a9a9b95189b4e650e

cargo fix --edition-idioms

ccarols10cents committed 5 years ago
Verified
e9d469ac4753306628f7ad5a34a32ef5d0d86d01

Switch to Rust Edition 2018

ccarols10cents committed 5 years ago
Verified
03ef1bc94815c5c103ab6543abee51b5536bbade

Switch from try to ?

ccarols10cents committed 5 years ago
Verified
08bae708bd8e084068cee5508c74d632feb05c55

rustfmt

ccarols10cents committed 5 years ago
Verified
0edf6f2ab4343c316241b82943c7719f5c042daf

Resolve warning by using dirs::home_dir

ccarols10cents committed 5 years ago

README

The README file for this repository.

cargo open

Build Status

A third-party cargo extension to allow you to open a dependent crate in your $EDITOR. Heavily inspired by bundle open!

Compiling

I'm assuming you already have Rust and cargo set up.

Clone this repository and go into the created directory:

git clone https://github.com/carols10cents/cargo-open.git
cd cargo-open

And compile a release version:

cargo build --release

You should now have an executable in [starting directory]/cargo-open/target/release/cargo-open.

Installing and Using

Compile the code as shown in the previous section, then put the cargo-open executable in your PATH.

My favorite way of doing this is I have a pre-existing directory in ~/bin that contains little scripts of mine, that dir is added to my PATH in my .bashrc so that it's always available, and then I symlink the release version from where it exists to that directory:

ln -s [starting directory]/cargo-open/target/release/cargo-open ~/bin/

Once you've done that, because of the way cargo is set up to use third party extensions, in any other Rust project of yours, you should be able to run:

cargo open [some crate you're using]

and that crate will open in your desired editor.

cargo open determines your desired editor by first checking $CARGO_EDITOR, then $VISUAL, then $EDITOR. It will fail with a hopefully-helpful error message if none of these are set.

Contributing

Pull requests, bug reports, and feature requests are all welcome! <3 <3 <3

If you'd like to work on your own version of the code, fork this repo and follow the Compiling steps above except with your fork.

One weird thing if you're running the binary directly instead of through the cargo plugin system is that clap doesn't think you're using a subcommand. If you try, you'll get:

$ ./target/release/cargo-open whatever
error: Found argument 'whatever', but cargo wasn't expecting any

USAGE:
        cargo <SUBCOMMAND>

For more information try --help

To get around this, either follow the Installation and Usage instructions above and always use cargo open whatever or re-specify open as the subcommand:

./target/release/cargo-open open whatever

Running tests

Because the tests set and get environment variables, and that isn't guaranteed to be safe to access concurrently, the tests will sometimes fail unless you run them with one thread:

$ RUST_TEST_THREADS=1 cargo test

Using this command, the tests should always pass.

TODO

Please see this repo's issues for things I intend to add someday, and file new issues for anything you think is missing!

I've also labeled issues with "E-easy" for ones that I think would be easy to pick up if you would like to help-- please ask for clarification if any of them are unclear!

License

cargo open is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0).

See LICENSE-APACHE and LICENSE-MIT for details.