Package io.jawk
Class Cli
java.lang.Object
io.jawk.Cli
Command-line interface for Jawk.
-
Constructor Summary
ConstructorsConstructorDescriptionCli()Creates a CLI instance wired to the standard input and output streams.Cli(InputStream in, PrintStream out, PrintStream err) Creates a CLI instance using the supplied streams. -
Method Summary
Modifier and TypeMethodDescriptionstatic Clicreate(String[] args, InputStream is, PrintStream os, PrintStream es) Convenience factory that parses arguments, executes the CLI, and returns the configured instance.Returns the precompiled program loaded via the-Loption, if any.Returns the list of script sources specified on the command line.Returns the mutableAwkSettingsconfigured from the command line.booleanIndicates whether tuple optimization was explicitly disabled.booleanIndicates whether runtime profiling was requested.booleanIndicates whether sandbox mode was requested on the command line.static voidEntry point for the command-line interface.voidParses the supplied command-line arguments and configures this instance accordingly.static CliparseCommandLineArguments(String[] args) Parses command-line arguments into a newCliinstance without executing it.voidrun()Executes the CLI based on the previously parsed arguments.
-
Constructor Details
-
Cli
public Cli()Creates a CLI instance wired to the standard input and output streams. -
Cli
Creates a CLI instance using the supplied streams.- Parameters:
in- stream from which program input is readout- stream where program output is writtenerr- stream where error messages could be written
-
-
Method Details
-
getSettings
Returns the mutableAwkSettingsconfigured from the command line.- Returns:
- the settings object populated during argument parsing
-
isSandbox
public boolean isSandbox()Indicates whether sandbox mode was requested on the command line.- Returns:
truewhen sandbox mode is enabled
-
isDisableOptimize
public boolean isDisableOptimize()Indicates whether tuple optimization was explicitly disabled.- Returns:
truewhen optimization should be skipped
-
isProfiling
public boolean isProfiling()Indicates whether runtime profiling was requested.- Returns:
truewhen profiling should be enabled
-
getScriptSources
Returns the list of script sources specified on the command line.- Returns:
- defensive copy of the script sources list
-
getPrecompiledProgram
Returns the precompiled program loaded via the-Loption, if any.- Returns:
- the program or
nullif none were loaded
-
parse
Parses the supplied command-line arguments and configures this instance accordingly.- Parameters:
args- command-line arguments
-
run
Executes the CLI based on the previously parsed arguments.- Throws:
Exception- if compilation or execution fails
-
parseCommandLineArguments
Parses command-line arguments into a newCliinstance 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 argumentsis- input stream for program inputos- output stream for program outputes- error stream for diagnostic messages- Returns:
- configured and executed CLI instance
- Throws:
Exception- if execution fails
-
main
Entry point for the command-line interface.- Parameters:
args- command-line arguments
-