Class LineInvoker


  • public class LineInvoker
    extends java.lang.Object
    Invokes the Stilts tasks using a LineTableEnvironment.
    Since:
    15 Aug 2005
    Author:
    Mark Taylor
    • Constructor Summary

      Constructors 
      Constructor Description
      LineInvoker​(java.lang.String toolName, uk.ac.starlink.util.ObjectFactory<uk.ac.starlink.task.Task> taskFactory)
      Constructor.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getParamHelp​(TableEnvironment env, java.lang.String taskName, uk.ac.starlink.task.Parameter param)
      Returns a help string for a parameter of one of the tasks known to this application.
      static java.lang.String getPrefixedParameterUsage​(uk.ac.starlink.task.Parameter[] params, java.lang.String prefix)
      Returns a usage string for a set of parameters, prefixed by a given string.
      static java.lang.String getStackSummary​(java.lang.Throwable error)
      Returns a truncated version of a stack trace for user consumption.
      static java.lang.String getUnusedWarning​(java.lang.String[] unused)
      Returns a warning string appropriate for the case when one or more words on the command line are never used by a task.
      int invoke​(java.lang.String[] args, java.lang.Runnable loggedConfig)
      Invokes one of the known tasks given a string of command-line words.
      • Methods inherited from class java.lang.Object

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

      • LineInvoker

        public LineInvoker​(java.lang.String toolName,
                           uk.ac.starlink.util.ObjectFactory<uk.ac.starlink.task.Task> taskFactory)
        Constructor.
        Parameters:
        toolName - name of the overall application
        taskFactory - factory which can create the tasks known to the application
    • Method Detail

      • invoke

        public int invoke​(java.lang.String[] args,
                          java.lang.Runnable loggedConfig)
        Invokes one of the known tasks given a string of command-line words. The args string will typically come straight out of a static main() method. A callback may be supplied to perform configuration that has to be done after logging configuration - presumably because it does some logging itself. It is executed synchronously.
        Parameters:
        args - argument list
        loggedConfig - callback for configuration to be done after logging configuration (may be null)
      • getStackSummary

        public static java.lang.String getStackSummary​(java.lang.Throwable error)
        Returns a truncated version of a stack trace for user consumption. This gives the error message for each throwable in the cause chain, but not line numbers etc.
        Parameters:
        error - exception to summarise
        Returns:
        multiline text summary
      • getPrefixedParameterUsage

        public static java.lang.String getPrefixedParameterUsage​(uk.ac.starlink.task.Parameter[] params,
                                                                 java.lang.String prefix)
        Returns a usage string for a set of parameters, prefixed by a given string.
        Parameters:
        params - parameter array
        prefix - string to prepend to the first line
        Returns:
        usage string
      • getParamHelp

        public static java.lang.String getParamHelp​(TableEnvironment env,
                                                    java.lang.String taskName,
                                                    uk.ac.starlink.task.Parameter param)
        Returns a help string for a parameter of one of the tasks known to this application. May include extended usage information. Consider the result to be a formatted string, that is, one which contains newlines to keep line lengths down to a reasonable level.
        Parameters:
        env - execution environment
        taskName - task nickname - may be null if heading is not required
        param - parameter for which usage information is required
        Returns:
        usage message
      • getUnusedWarning

        public static java.lang.String getUnusedWarning​(java.lang.String[] unused)
        Returns a warning string appropriate for the case when one or more words on the command line are never used by a task.
        Parameters:
        unused - unused words
        Returns:
        warning lines