-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Usage string should not use main when calling a script #7126
Comments
Hmm, I'm a little confused by your expected behaviour. I can see how the current output is confusing, but given that you're running it like What about
Or even
|
Sorry, that was an oversight on my part. Yes, it should be |
Oh, I was thinking of literally outputting I see that you've updated your expected behaviour to:
I still think that's a little off, because the user can't actually run the script like that. I'm thinking it would make more sense to suggest |
Looking at some cursory SO answers, I'm fairly certain the UNIX standard is to use just the base name of the script in the usage section.
It depends on the contents of the script. I would expect in most cases that a shebang would be provided, in which case it's more than possible to execute the script without invoking |
Shebangs are only available on *nix OSs and we don't have a guarantee that the script contains one (although I guess we could check). |
True. I'll leave it up to the core team to decide on what looks better. My experience has been the usage line contains only the base name of the script and/or binary. I suppose a (potentially more difficult) alternative is to let the script author control what gets put there. They already have some level of control using comments. |
Spent a bit of time looking at this and it's sadly not quite trivial to fix. At the point where the help content is generated, the engine is not aware of the script file - it's just handling a call to a regular command named Might come back to this another time, but if someone else wants to pick it up here are the relevant bits: nushell/crates/nu-cli/src/eval_file.rs Lines 39 to 53 in 8e4b85e
nushell/crates/nu-engine/src/eval.rs Lines 41 to 46 in 8e4b85e
|
Yes, that was the same conclusion I had drawn earlier. Piping the context of the script name all the way to where the help is generated is not a straightforward task, unfortunately. |
Describe the bug
When executing a script and passing the help flag (
nu myscript.nu --help
), the usage string utilizesmain
as the executable.How to reproduce
main
functionnu myscript.nu --help
Expected behavior
For the uninitiated, the usage of
main
as the executable can be confusing. It would be more natural to include the name of the script:Screenshots
No response
Configuration
N/A
Additional context
No response
The text was updated successfully, but these errors were encountered: