summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorStef Walter <stefw@gnome.org>2013-03-11 09:50:38 +0100
committerStef Walter <stefw@gnome.org>2013-03-11 09:55:55 +0100
commit22993290d75bacb33c177be8ee2bc78ea0687ac8 (patch)
treeee612c300178637ac3069cc842dfdc10827c3219 /tools
parentc80956aef3abaa90fa9ab7c2873a45adbe127dc4 (diff)
tools: Display per-command help appropriately
* Fixes a regression * In addition allows --help to be specified before the command. If a command is present, command help will be shown https://bugs.freedesktop.org/show_bug.cgi?id=62153
Diffstat (limited to 'tools')
-rw-r--r--tools/tool.c19
1 files changed, 12 insertions, 7 deletions
diff --git a/tools/tool.c b/tools/tool.c
index e9c10a0..fa68eed 100644
--- a/tools/tool.c
+++ b/tools/tool.c
@@ -229,6 +229,7 @@ int
main (int argc, char *argv[])
{
char *command = NULL;
+ bool want_help = false;
bool skip;
int in, out;
int i;
@@ -267,8 +268,7 @@ main (int argc, char *argv[])
quiet_arg ();
} else if (strcmp (argv[in], "--help") == 0) {
- command_usage ();
- return 0;
+ want_help = true;
} else if (!command) {
p11_message ("unknown global option: %s", argv[in]);
@@ -282,8 +282,8 @@ main (int argc, char *argv[])
for (i = 1; argv[in][i] != '\0'; i++) {
switch (argv[in][i]) {
case 'h':
- command_usage ();
- return 0;
+ want_help = true;
+ break;
/* Compatibility option */
case 'l':
@@ -320,11 +320,16 @@ main (int argc, char *argv[])
if (command == NULL) {
/* As a special favor if someone just typed 'p11-kit', help them out */
- if (argc == 1)
+ if (argc == 1) {
command_usage ();
- else
+ return 2;
+ } else if (want_help) {
+ command_usage ();
+ return 0;
+ } else {
p11_message ("no command specified");
- return 2;
+ return 2;
+ }
}
argc = out;