-
How can I add the |
Beta Was this translation helpful? Give feedback.
Answered by
DannyBen
Nov 27, 2022
Replies: 1 comment 2 replies
-
Basically, you just create the command as you normally would, and have its code call the internal bashly help functions. There is an example for that: This is the important bit: # src/help_command.sh
command="${args[command]}"
long_usage=yes
if [[ -z "$command" ]]; then
# No command argument, show the global help
help_function=cli_usage
else
# Show the help for the requested command
help_function="cli_${command}_usage"
fi
# Call the help function if it exists
if [[ $(type -t "$help_function") ]]; then
"$help_function"
else
echo "No help available for this command"
exit 1
fi Since this is not the first time this was asked, I wonder if there should be a simpler way to do this. |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Basically, you just create the command as you normally would, and have its code call the internal bashly help functions.
There is an example for that:
https://github.com/DannyBen/bashly/tree/master/examples/help-command#readme
This is the important bit:
Since this is not the fi…