Discussed in #526
Originally posted by codevogel July 4, 2024
Say I have a bashly script foo that I run with ./foo
In my bashly.yml I have
commands:
- name: do
help: do something with my_arg
default: force
args:
- name: my_arg
help: my argument to be handled
required: true
if I then run ./foo I get
❯ ./foo
missing required argument: MY_ARG
usage: foo do MY_ARG
This could be somewhat confusing to a new user, as they have just done foo, not foo do.
Also, ./foo MY_ARG would also be sufficient usage.
So, it would be nice if it instead printed
❯ ./foo
missing required argument: MY_ARG
usage: foo do MY_ARG
foo MY_ARG
I don't see how I could achieve this with one of the custom_strings, as this would be behavior that is specific to the forced command only.
I tried looking at adding a src/after.sh to evaluate the last line of the output and seeing if it starts with usage: foo do to echo usage: foo MY_ARG, but after.sh does not run if the script already exists due to catching a usage error. It also seems like bad practice to do this with a before.sh
What would be the best way to enable this?
(An alternative way to render this would be something like)
❯ ./foo
missing required argument: MY_ARG
usage: foo MY_ARG
foo do MY_ARG
or
❯ ./foo
missing required argument: MY_ARG
usage: foo do MY_ARG
( or: foo MY_ARG )
```</div>
Discussed in #526
Originally posted by codevogel July 4, 2024
Say I have a bashly script
foothat I run with./fooIn my
bashly.ymlI haveif I then run
./fooI getThis could be somewhat confusing to a new user, as they have just done
foo, notfoo do.Also,
./foo MY_ARGwould also be sufficient usage.So, it would be nice if it instead printed
I don't see how I could achieve this with one of the
custom_strings, as this would be behavior that is specific to theforcedcommand only.I tried looking at adding a
src/after.shto evaluate the last line of the output and seeing if it starts withusage: foo doto echousage: foo MY_ARG, butafter.shdoes not run if the script already exists due to catching a usage error. It also seems like bad practice to do this with abefore.shWhat would be the best way to enable this?
(An alternative way to render this would be something like)
or