Class CmdUtils

java.lang.Object
org.aksw.commons.picocli.CmdUtils

public class CmdUtils extends Object
callCmd: Run command and return the exit code execCmd: Run command and terminate the JVM using System.exit with the exit code
Author:
raven
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static int
    callCmd(Class<?> cmdClass, String[] args)
     
    static int
    callCmd(picocli.CommandLine cl, String[] args)
     
    static int
    callCmdObject(Object cmdInstance, String[] args)
    Utility method to launch a command with a generally useful exception handling configuration: If the command supports HasDebugMode then display of exception is as follows: on: the full stack trace is shown off: only the root cause message (without the stack trace) of an exception is shown If the debug flag is not supported then the output matches the debug=on case (full stack trace is shown).
    static void
    execCmd(Class<?> cmdClass, String[] args)
     
    static void
    execCmd(picocli.CommandLine cl, String[] args)
     
    static void
    execCmdObject(Object cmdInstance, String[] args)
     
    static picocli.CommandLine
    registerIfAvailable(picocli.CommandLine commandLine, String className)
    Attempt to register a command by class name.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • CmdUtils

      public CmdUtils()
  • Method Details

    • execCmd

      public static void execCmd(Class<?> cmdClass, String[] args)
    • execCmdObject

      public static void execCmdObject(Object cmdInstance, String[] args)
    • execCmd

      public static void execCmd(picocli.CommandLine cl, String[] args)
    • callCmd

      public static int callCmd(Class<?> cmdClass, String[] args)
      Parameters:
      args - The application arguments
      cmdClass - Command class with no arg ctor
      Returns:
    • callCmdObject

      public static int callCmdObject(Object cmdInstance, String[] args)
      Utility method to launch a command with a generally useful exception handling configuration: If the command supports HasDebugMode then display of exception is as follows: on: the full stack trace is shown off: only the root cause message (without the stack trace) of an exception is shown If the debug flag is not supported then the output matches the debug=on case (full stack trace is shown).
      Parameters:
      args -
      cmdInstance -
      Returns:
    • callCmd

      public static int callCmd(picocli.CommandLine cl, String[] args)
    • registerIfAvailable

      public static picocli.CommandLine registerIfAvailable(picocli.CommandLine commandLine, String className)
      Attempt to register a command by class name. If a ClassNotFoundException is raised then the command is ignored. Useful to deal with commands provided by maven dependencies that may needed to be excluded.