Skip to content
Discussion options

You must be logged in to vote

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:

# 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 fi…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@ghost
Comment options

@DannyBen
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant