-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Automated way to create an alias for cargo subcommand? #9061
Comments
You actually have the capability of stating these aliases. See the docs. I'm not sure if I really understand the details of your issue but what you're trying to do may be doable by adding to the A better option anyway is to maybe display some message suggesting to add the alias to the config. Since users might have it symlinked or many other stuff that you might want to avoid dealing with. I'm not sure wether this can be done on any other way. |
there's minor problems with both of the posts above. for example, |
This seems to be the right link: https://doc.rust-lang.org/cargo/reference/config.html#alias But it does not work for me with or without the #[alias]
cov = "llvm-cov --lcov --output-path=./coverage/lcov.info" [alias]
cov = "llvm-cov --lcov --output-path=./coverage/lcov.info" |
@josecelano, if you're talking about how aliases work in genernal, that should just work when the configuration file is in one of the paths of configuration discovery, and have a |
Thank you @weihanglo. It works now using |
This demo file was originally from a demo I made back on July 30. I figured out how to get a sort of 'npm run dev' kind of thing working, I really like it! This kind of quick-feedback programming is how I get things done fast, as I can easily see when things go right, or wrong. https://doc.rust-lang.org/rust-by-example/custom_types/structs.html https://doc.rust-lang.org/book/ch16-01-threads.html https://www.reddit.com/r/rust/comments/9twt89/show_rrust_cargocmd_like_npm_scripts_but_for_cargo/ (I was curious if you could do something like `cargo run dev` for this kind of hot reload script, but it didn't seem to work from what I tried. It is possible it sounds like, but I don't think I'm implementing it right. Going to use a Bash script for the meantime. I want it to work cross-platform though, so you can use this on Windows too and not have to do anything special for that. I know I could make a Batch file, but I'd rather use simple tooling with Cargo than roll my own thing for that. That's the same case with npm as well, to use the tools that are available to you! :D) https://doc.rust-lang.org/cargo/reference/config.html#alias https://pseitz.github.io/toml-to-json-online-converter/ (Neat concept, finding the similarities between TOML, JSON, and SNBT/NBT) rust-lang/cargo#9061 rust-lang/cargo#8486 (comment) (Is my alias not working because of how I defined it in the config?)
Describe the problem you are trying to solve
I am trying to create an alias for cargo-generate.
The crate
cargo-generate
is automatically used when executingcargo generate
.With the help of
structopt
, we created an alias calledgen
to executecargo-generate
usingcargo run -- gen
instead ofcargo run -- generate
.After installing the crate locally (
cargo install --path .
), the current way to executecargo generate
is to letcargo
make an invocation of an external toolcargo-${command}
, socargo gen
is an unknown command tocargo
.Describe the solution you'd like
A solution to create aliases is to generate a file called
config
inside$HOME/.cargo
, and fill it with an alias, like this:but this method needs a manual intervention from the user.
I would like to know if it exists an "automated" way to create this alias easily after installing the crate on a system, or not.
Notes
Original issue, posted in cargo-generate, here.
Thanks a lot!
The text was updated successfully, but these errors were encountered: