Skip to content
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

Program name (bin_name) should be configurable #134

Closed
DanielKeep opened this issue May 30, 2015 · 7 comments
Closed

Program name (bin_name) should be configurable #134

DanielKeep opened this issue May 30, 2015 · 7 comments
Assignees
Labels
C-enhancement Category: Raise on the bar on expectations

Comments

@DanielKeep
Copy link

The first line of the --help message for my program is as follows:

cargo-script.exe-script 0.1.1

The obvious issue is that this is hideously ugly, and also misleading. I'm writing a Cargo subcommand and, as such, the user is never going to invoke this program as "cargo-script". I need to tell clap that the program should identify itself as "cargo". Ideally, I'd be able to tell it to lie when using the "script" subcommand, but not when it isn't provided.

I thought about just altering the arguments clap is parsing, but there doesn't appear to be any way to do this.

Also, it would help to not have the file extension present in the name.

@kbknapp
Copy link
Member

kbknapp commented May 30, 2015

This shouldn't be too hard, let me play with an implementation idea and I'll post back here. Thanks for taking the time to file this!

@kbknapp kbknapp added the C-enhancement Category: Raise on the bar on expectations label May 30, 2015
@kbknapp kbknapp self-assigned this May 30, 2015
@DanielKeep
Copy link
Author

No problem. If it's of any use, the code in question is in cargo-script/v0.1.1.

@kbknapp
Copy link
Member

kbknapp commented May 30, 2015

Thanks! I was just about to ask. So ideally, you'd like to be able to say the bin_name of the parent command is cargo and you've got a subcommand of script which in the help/version should be dispalyed as:

$ cargo script -v
cargo-script v1.0

But in usage strings should be displayed as:

USAGE:
    cargo script <script>

Correct?

If that's the case I should have this working in about 10 minutes ;)

@DanielKeep
Copy link
Author

Pretty much, yeah. So long as it doesn't call itself cargo-script-script or cargo.exe script, it's all good. :)

@kbknapp
Copy link
Member

kbknapp commented May 30, 2015

Aright, I've got it working tested with this scenario. Uploading now, use 0.10.2 on crates.io
The relevant piece for you is on the App struct set the .bin_name("cargo") which allows you to override the system determined binary name with whatever you want. You could also use cargo.exe if you prefer, it could be anything.

@kbknapp
Copy link
Member

kbknapp commented May 30, 2015

It's up on crates.io now, you can also use the master branch here.

off topic, cargo script looks awesome! I'm going to have to keep an eye on this!

@DanielKeep
Copy link
Author

Thanks; updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-enhancement Category: Raise on the bar on expectations
Projects
None yet
Development

No branches or pull requests

2 participants