Record Class CLIOptions

java.lang.Object
java.lang.Record
ortus.boxlang.runtime.config.CLIOptions
Record Components:
templatePath - The path to the template to execute. Can be a class or template. Mutally exclusive with code
debug - Whether or not to run in debug mode. It can be `null` if not specified
code - The source code to execute, if any
configFile - The path to the config file to use
printAST - Whether or not to print the AST of the source code
transpile - Whether or not to transpile the source code to Java
runtimeHome - The path to the runtime home
showVersion - Whether or not to show the version of the runtime
cliArgs - The arguments to pass to the template or class
cliArgsRaw - The raw arguments passed to the CLI
targetModule - The module to execute
actionCommand - The action command to execute

public record CLIOptions(String templatePath, Boolean debug, String code, String configFile, Boolean printAST, Boolean transpile, String runtimeHome, Boolean showVersion, List<String> cliArgs, String[] cliArgsRaw, String targetModule, String actionCommand) extends Record
Command-line options for the BoxLang runtime.
  • Constructor Details

    • CLIOptions

      public CLIOptions(String templatePath, Boolean debug, String code, String configFile, Boolean printAST, Boolean transpile, String runtimeHome, Boolean showVersion, List<String> cliArgs, String[] cliArgsRaw, String targetModule, String actionCommand)
      Creates an instance of a CLIOptions record class.
      Parameters:
      templatePath - the value for the templatePath record component
      debug - the value for the debug record component
      code - the value for the code record component
      configFile - the value for the configFile record component
      printAST - the value for the printAST record component
      transpile - the value for the transpile record component
      runtimeHome - the value for the runtimeHome record component
      showVersion - the value for the showVersion record component
      cliArgs - the value for the cliArgs record component
      cliArgsRaw - the value for the cliArgsRaw record component
      targetModule - the value for the targetModule record component
      actionCommand - the value for the actionCommand record component
  • Method Details

    • isActionCommand

      public Boolean isActionCommand()
      Wether or not this is an action command: Ex: boxlang compile
      Returns:
      True if it is an action command, false otherwise
    • isDebugMode

      public boolean isDebugMode()
      Verifies if debug mode was enabled
      Returns:
      True if debug mode is enabled, false otherwise
    • parseArguments

      public IStruct parseArguments()
      Quick parser for options on cli arguments for BoxLang

      This method will parse the cli arguments and return a struct of the following:

      • options - A struct of the options
      • positionals - An array of the positional arguments

      The options can be provided in the following formats:

      • --option - A boolean option
      • --option=value - An option with a value
      • --option="value" - An option with a quoted value
      • --option='value' - An option with a quoted value
      • -o=value - A shorthand option with a value
      • -o - A shorthand boolean option
      • --!option - A negation option

      For example, the following cli arguments:

       --debug --!verbose --bundles=Spec -o='/path/to/file' -v my/path/template
       

      Will be parsed into the following struct:

       {
       "options" :  {
              "debug": true,
              "verbose": false,
              "bundles": "Spec",
                      "o": "/path/to/file",
                      "v": true
       },
       "positionals": [ "my/path/template" ]
       

      Some Ground Rules

      • Options are prefixed with --
      • Shorthand options are prefixed with -
      • Options can be negated with --! or --no-
      • Options can have values separated by =
      • Values can be quoted with single or double quotes
      • Repeated options will override the previous value
      Returns:
      A struct of the options and positional arguments
    • toStruct

      public IStruct toStruct()
      Get the state representation of this record
      Returns:
      The state representation of this record as a struct
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • templatePath

      public String templatePath()
      Returns the value of the templatePath record component.
      Returns:
      the value of the templatePath record component
    • debug

      public Boolean debug()
      Returns the value of the debug record component.
      Returns:
      the value of the debug record component
    • code

      public String code()
      Returns the value of the code record component.
      Returns:
      the value of the code record component
    • configFile

      public String configFile()
      Returns the value of the configFile record component.
      Returns:
      the value of the configFile record component
    • printAST

      public Boolean printAST()
      Returns the value of the printAST record component.
      Returns:
      the value of the printAST record component
    • transpile

      public Boolean transpile()
      Returns the value of the transpile record component.
      Returns:
      the value of the transpile record component
    • runtimeHome

      public String runtimeHome()
      Returns the value of the runtimeHome record component.
      Returns:
      the value of the runtimeHome record component
    • showVersion

      public Boolean showVersion()
      Returns the value of the showVersion record component.
      Returns:
      the value of the showVersion record component
    • cliArgs

      public List<String> cliArgs()
      Returns the value of the cliArgs record component.
      Returns:
      the value of the cliArgs record component
    • cliArgsRaw

      public String[] cliArgsRaw()
      Returns the value of the cliArgsRaw record component.
      Returns:
      the value of the cliArgsRaw record component
    • targetModule

      public String targetModule()
      Returns the value of the targetModule record component.
      Returns:
      the value of the targetModule record component
    • actionCommand

      public String actionCommand()
      Returns the value of the actionCommand record component.
      Returns:
      the value of the actionCommand record component