Class Cli

java.lang.Object
org.metricshub.jawk.Cli

public final class Cli extends Object
Command-line interface for Jawk.
  • Constructor Details

    • Cli

      public Cli()
      Creates a CLI instance wired to the standard input and output streams.
    • Cli

      public Cli(InputStream in, PrintStream out, PrintStream err)
      Creates a CLI instance using the supplied streams. The error stream is currently unused but kept for API symmetry with typical Java main methods.
      Parameters:
      in - stream from which program input is read
      out - stream where program output is written
      err - stream where error messages could be written
  • Method Details

    • getSettings

      public AwkSettings getSettings()
      Returns the mutable AwkSettings configured from the command line.
      Returns:
      the settings object populated during argument parsing
    • isSandbox

      public boolean isSandbox()
    • getScriptSources

      public List<ScriptSource> getScriptSources()
      Returns the list of script sources specified on the command line.
      Returns:
      defensive copy of the script sources list
    • getPrecompiledTuples

      public AwkTuples getPrecompiledTuples()
      Returns the precompiled tuples loaded via the -L option, if any.
      Returns:
      the tuples or null if none were loaded
    • parse

      public void parse(String[] args)
      Parses the supplied command-line arguments and configures this instance accordingly.
      Parameters:
      args - command-line arguments
    • run

      public void run() throws Exception
      Executes the CLI based on the previously parsed arguments.
      Throws:
      Exception - if compilation or execution fails
    • parseCommandLineArguments

      public static Cli parseCommandLineArguments(String[] args)
      Parses command-line arguments into a new Cli instance without executing it.
      Parameters:
      args - command-line arguments
      Returns:
      configured CLI instance
    • create

      public static Cli create(String[] args, InputStream is, PrintStream os, PrintStream es) throws Exception
      Convenience factory that parses arguments, executes the CLI, and returns the configured instance.
      Parameters:
      args - command-line arguments
      is - input stream for program input
      os - output stream for program output
      es - error stream for diagnostic messages
      Returns:
      configured and executed CLI instance
      Throws:
      Exception - if execution fails
    • main

      public static void main(String[] args)
      Entry point for the command-line interface.
      Parameters:
      args - command-line arguments