jwaldrip / admiral.cr

A robust DSL for writing command line interfaces written in Crystal.
https://jwaldrip.github.com/admiral.cr
MIT License
135 stars 14 forks source link

Exit status for unknown command/subcommand #27

Closed n-rodriguez closed 1 year ago

n-rodriguez commented 1 year ago

When command or subcommand is unknown the default behavior is to print help and exit 0 :

Usage:
  /home/nonroot/.asdf/installs/squarectl/1.4.0/bin/squarectl compose [flags...] [arg...]
Run Docker Compose commands
Flags:
  --config, -c (default: "squarectl.yml")  # Path to config file
  --help                                   # Displays help for the current command.
Subcommands:
  build                                    # Run docker-compose build
  clean                                    # Run docker-compose clean
  config                                   # Run docker-compose config
  down                                     # Run docker-compose down
  exec                                     # Run docker-compose exec
  ps                                       # Run docker-compose ps
  setup                                    # Run docker-compose setup
  start                                    # Run docker-compose start
  stop                                     # Run docker-compose stop
  top                                      # Run docker-compose top
  up                                       # Run docker-compose up
* Done!
Job succeeded

It would be nice to notify user about the missing command, something like Unknow "squarectl compose push" command and to exit 1,

Thank you!

Note: this issue has been found while working on https://github.com/jbox-web/squarectl

n-rodriguez commented 1 year ago

Actually it was my fault : https://github.com/jbox-web/squarectl/blob/3f1be1861d8e46540f53e6bbb26da06d4cf2858f/src/squarectl/cli.cr#L15-L17

I managed to handle the case like this : https://github.com/jbox-web/squarectl/commit/dbabe261dbbd871fed7dd546c92fcb47a81cdd8b