From ab1f28b71b10f8a43d3812899dc04d55c3ad84d0 Mon Sep 17 00:00:00 2001 From: Jan Kupec Date: Sun, 9 Dec 2007 11:27:27 +0000 Subject: [PATCH] - show help by default if no option or command was specified (#346507) - show help if --help is specified :O) --- src/zypper.cc | 25 ++++++++++++++----------- test/test-cases/help | 5 +++++ 2 files changed, 19 insertions(+), 11 deletions(-) diff --git a/src/zypper.cc b/src/zypper.cc index b7bdbe7..5e29736 100644 --- a/src/zypper.cc +++ b/src/zypper.cc @@ -334,17 +334,18 @@ void Zypper::processGlobalOptions() } // get command - try + if (optind < _argc) { - if (optind < _argc) - setCommand(ZypperCommand(_argv[optind++])); - } - // exception from command parsing - catch (Exception & e) - { - cerr << e.asUserString() << endl; - setCommand(ZypperCommand::NONE); + try { setCommand(ZypperCommand(_argv[optind++])); } + // exception from command parsing + catch (Exception & e) + { + cerr << e.asUserString() << endl; + //setCommand(ZypperCommand::NONE); + } } + else + setRunningHelp(); if (command() == ZypperCommand::HELP) { @@ -371,7 +372,9 @@ void Zypper::processGlobalOptions() } else if (command() == ZypperCommand::NONE) { - if (gopts.count("version")) + if (runningHelp()) + print_main_help(); + else if (gopts.count("version")) cout << PACKAGE " " VERSION << endl; else { @@ -501,7 +504,7 @@ void Zypper::safeDoCommand() try { processCommandOptions(); - if (exiting()) + if (exiting() || command() == ZypperCommand::NONE) return; doCommand(); } diff --git a/test/test-cases/help b/test/test-cases/help index 54f9c94..a2f9eec 100644 --- a/test/test-cases/help +++ b/test/test-cases/help @@ -1,4 +1,6 @@ +- zypper - zypper help +- zypper -h show list of global options and list of commands - zypper help help @@ -24,6 +26,9 @@ in shell +- empty line entered + show unknown command hint + - help show list of global options and list of commands -- 2.7.4