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

Update default command usage to show optional brackets #529

Merged
merged 1 commit into from
Jul 5, 2024

Conversation

DannyBen
Copy link
Owner

@DannyBen DannyBen commented Jul 5, 2024

cc #526, #527

This PR updates the usage string for commands that are set as default.

# Before
$ ./cli src
missing required argument: TARGET
usage: cli download SOURCE TARGET

# After
$ ./cli src
missing required argument: TARGET
usage: cli [download] SOURCE TARGET

@DannyBen DannyBen merged commit 5e9e322 into master Jul 5, 2024
8 checks passed
@DannyBen DannyBen deleted the fix/default-command-usage branch July 5, 2024 07:49
@codevogel
Copy link

I cloned master and built it with ruby 3.3.3.

This seems to work as expected on my end.

with bashly.yml

name: pls
help: "Project Level Shortcuts - A simple tool to manage project specific aliases."
version: 0.1.0

environment_variables:
- name: pls_default
  help: Path to the root configuration file (The fallback .pls file if is is not found in the current working directory or any of its parents)
  default: $HOME/.pls

commands:
  - name: do
    help: Executes the command associated with the given alias
    default: force
    args:
      - name: alias
        help: The alias to execute
        required: true
    examples:
      - pls open
      - pls do open

The help message shows

❯ ./pls --help
pls - Project Level Shortcuts - A simple tool to manage project specific aliases.

Usage:
  pls [COMMAND]
  pls [COMMAND] --help | -h
  pls --version | -v

Commands:
  do   Executes the command associated with the given alias (default)

Options:
  --help, -h
    Show this help

  --version, -v
    Show version number

Environment Variables:
  PLS_DEFAULT
    Path to the root configuration file (The fallback .pls file if is is not
    found in the current working directory or any of its parents)
    Default: /home/codevogel/.pls

and

❯ ./pls do --help
pls do - Executes the command associated with the given alias

Usage:
  pls [do] ALIAS
  pls do --help | -h

Options:
  --help, -h
    Show this help

Arguments:
  ALIAS
    The alias to execute

Examples:
  pls open
  pls do open

So it shows that do is the default, and it also shows that that means do is optional.

Great work 🥳

@DannyBen
Copy link
Owner Author

DannyBen commented Jul 5, 2024

Notice that this also changed:

$ ./pls
missing required argument: ALIAS
usage: pls [do] ALIAS

@codevogel
Copy link

Notice that this also changed:

$ ./pls
missing required argument: ALIAS
usage: pls [do] ALIAS

Forgot to mention that. It perfectly addresses my original issue!

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

Successfully merging this pull request may close these issues.

2 participants