Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.
/ cargo-open Public archive

A third-party cargo extension to allow you to open a dependent crate in your $EDITOR

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

carols10cents/cargo-open

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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.

About

A third-party cargo extension to allow you to open a dependent crate in your $EDITOR

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

Watchers

Forks

Packages

No packages published

Languages