- show help by default if no option or command was specified (#346507)
authorJan Kupec <jkupec@suse.cz>
Sun, 9 Dec 2007 11:27:27 +0000 (11:27 +0000)
committerJan Kupec <jkupec@suse.cz>
Sun, 9 Dec 2007 11:27:27 +0000 (11:27 +0000)
- show help if --help is specified :O)

src/zypper.cc
test/test-cases/help

index b7bdbe7..5e29736 100644 (file)
@@ -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();
   }
index 54f9c94..a2f9eec 100644 (file)
@@ -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