[Discussion] Replacing "$0" with the executing file's base name #983
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes the behavior of the
$0
token (when used within the contents of theusage
,epilog
and/orexample
methods), so that it displays the executing file's basename, as opposed to the full path. This has the affect of providing default help text that is closer to what the end-user would actually run, since they would likely be running the CLI on their path (or via anpackage.json
script), as opposed to using the CLI's entrypoint script path.This is a breaking change, but since #975 introduces a breaking change for the
usage
method, I figured I'd put this PR out for discussion's sake. I updated all of the tests to ensure they still pass, but there may be other scenarios that this change would break, so I'd love some feedback.I'm also not entirely sure this is the right behavior (e.h. as opposed to introducing a new token ala
$$0
or something, etc.), and I'm sure this conversation has been had a bunch of times already, so I'd love feedback and/or pointers to an existing/better solution for this. Thanks!Before this change (using a Yargs-based CLI named
kyte
):After this change:
CC @bcoe