cli: Exit with status 0 for --help
authorMichael Hanselmann <hansmi@google.com>
Tue, 2 Oct 2012 05:31:33 +0000 (07:31 +0200)
committerMichael Hanselmann <hansmi@google.com>
Tue, 2 Oct 2012 19:35:07 +0000 (21:35 +0200)
commitd971402f988becaf3e8d8d555ed03cb4482e09e5
tree3289432786a10a23b8713957a8a84ca43e5f2fc2
parentb0dcdc10906ba2a38bdc37f35a5b0fa3d5bf8d56
cli: Exit with status 0 for --help

This patch is somewhat longer than was anticipated. Before, commands like
“gnt-instance --help” would exit with the status code 1 (failure). With
this patch, those commands exits with 0 (success) while unknown commands
still print the usage screen and exit with status 1.

To achieve this goal without too much ugly code some refactoring on
cli._ParseArgs was necessary. Printing the version and usage screen was
separated. At the same time this allows for some unit testing.

Signed-off-by: Michael Hanselmann <hansmi@google.com>
Reviewed-by: Bernardo Dal Seno <bdalseno@google.com>
lib/cli.py
test/ganeti.cli_unittest.py
test/gnt-cli.test