Skip to content

Add ability to specify args for cargo #248

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

Closed
pravic opened this issue Feb 5, 2018 · 2 comments
Closed

Add ability to specify args for cargo #248

pravic opened this issue Feb 5, 2018 · 2 comments

Comments

@pravic
Copy link

pravic commented Feb 5, 2018

I am very excited about the new plugin version with the enhanced command handling (#165). However I have noticed that the arguments themselves are intended for a target itself rather than for rustc/cargo.

For example, "Rust Enhanced - Run (with args)" actually spawns cargo run -- ARGS rather than cargo run ARGS.

It would be convenient to run a particular binary, example or test, or whatever:

Run (with args): --example one => cargo run --example one
Run (with args): --bin one -- bin-args => cargo run --bin one -- bin-args

Sublime Text Version

Sublime Text 3 (Build 3156)

Rust Enhanced Version

2.8.0

Operating system

OS Name: Microsoft Windows 7 x64
Version: 6.1 Build 7601

References

Are there any other GitHub issues (open or closed) that should be linked here?

@ehuss
Copy link

ehuss commented Feb 5, 2018

There are multiple approaches you can take here.

If you just want to pick the target (such as --example one), I recommend using the "Automatic" build variant. It automatically picks the cargo command and target based on the view that is currently in focus. So if you have an example binary open, it will do cargo run --example foo. If you have a test file open, it will run cargo test --test bar.

You can manually specify the arguments via Sublime settings. Try running the command "Rust: Configure Cargo Build" which will assist you in configuring the settings. Most of the common settings are there, including a free-form "arguments" section (see docs).

Another approach is to create custom build variants. Run the command "Rust: Create New Cargo Build Variant". This will create a new build definition inside your .sublime-project file. You could use this to define a command cargo run --bin one -- my args, and then set that as your build variant. This is a more advanced approach, but allows you to define different setups that you can fairly easily switch between.

@pravic
Copy link
Author

pravic commented Feb 5, 2018

I recommend using the "Automatic" build variant.

Didn't know that. It works, thanks.

As for custom args that I would want to pass.. Well, let's do it manually in console still.

@pravic pravic closed this as completed Feb 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants