Commits

Sebastian Sdorra committed 01d0f87

added help option to SubCommand

  • Participants
  • Parent commits 3e7bc41

Comments (0)

Files changed (1)

File scm-clients/scm-cli-client/src/main/java/sonia/scm/cli/SubCommand.java

 
 import org.kohsuke.args4j.CmdLineException;
 import org.kohsuke.args4j.CmdLineParser;
+import org.kohsuke.args4j.Option;
 
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
     try
     {
       parser.parseArgument(args);
-      run();
+
+      if (help)
+      {
+        parser.printUsage(output, I18n.getBundle());
+        System.exit(1);
+      }
+      else
+      {
+        run();
+      }
     }
     catch (CmdLineException ex)
     {
   protected ScmClientSession session;
 
   /** Field description */
+  @Option(
+    name = "--help",
+    usage = "optionHelpText",
+    aliases = { "-h" }
+  )
+  private boolean help = false;
+
+  /** Field description */
   private boolean sessionRequired = true;
 }