Package: org.apache.groovy.groovysh

## [Groovy] Class Main

- org.apache.groovy.groovysh.Main

-     @SuppressWarnings(value="deprecation")
      class Main
      extends Object

  Boots and runs the interactive `groovysh` console.

- - ### Nested Class Summary

    Nested classes
    Modifiers | Name | Description
    --- | --- | ---
    `protected static class` | `Main.ExtraConsoleCommands` | Registers the extra console commands that augment the interactive shell.

  - ### Field Summary

    Fields
    Modifiers | Name | Description
    --- | --- | ---
    `static String` | `INTERPRETER_MODE_PREFERENCE_KEY` | Preference key that controls whether groovysh starts in interpreter mode.

  - ### Constructor Summary

    Constructors
    Constructor and description
    `Main()`

  - ### Methods Summary

    Methods
    Type Params | Return Type | Name and description
    --- | --- | ---
    `` | `static Path` | `createOwnerOnlyStateFile(Path file)` Ensures a file under the user state directory exists and is readable only by its owner.
    `` | `static Path` | `getUserStateDirectory()` Returns the user state directory used by groovysh for persisted files.
    `` | `static void` | `main(String[] args)` Launches groovysh as a standalone JVM process.
    `` | `static int` | `start(Map<String, ?> initialBindings, String[] args)` Programmatic entry point for embedding groovysh.
    `` | `static int` | `start(String[] args)` Programmatic entry point for embedding groovysh.
    `` | `static Path` | `tightenStateFile(Path file)` Restricts an existing state file to its owner when it is currently more permissive, and does nothing at all when the file is absent.

  - ### Inherited Methods Summary

    Inherited Methods
    Methods inherited from class | Name
    --- | ---
    `class Object` | `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Field Detail

    - #### public static final String INTERPRETER_MODE_PREFERENCE_KEY

      Preference key that controls whether groovysh starts in interpreter mode.

  - ### Constructor Detail

    - #### Main()

  - ### Method Detail

    - #### static Path createOwnerOnlyStateFile(Path file)

      Ensures a file under the user state directory exists and is readable only by its owner.

      These files record what was typed at the shell and the values it held, so on a shared host they should not be left at whatever the ambient umask happens to permit. A file that already exists is tightened only when it is currently more permissive than owner-only, so a deliberately-chosen mode is left alone. Failing to adjust permissions is not fatal: the file is still usable, and the shell should not refuse to start over it.

      Parameters:
        `file` - the state file
      Returns:
        the same path, for chaining

    - #### static Path getUserStateDirectory()

      Returns the user state directory used by groovysh for persisted files.

      Returns:
        the user-specific state directory

    - #### static void main(String[] args)

      Launches groovysh as a standalone JVM process.

      Parameters:
        `args` - command-line arguments

    - #### static int start(Map<String, ?> initialBindings, String[] args)

      Programmatic entry point for embedding groovysh.

      Parameters:
        `args` - CLI-like arguments (same as main(String[])).
        `initialBindings` - binding variables for the GroovyEngine
      Returns:
        process exit code (0 for success)
      Since:
        6.0.0

    - #### static int start(String[] args)

      Programmatic entry point for embedding groovysh.

      Parameters:
        `args` - CLI-like arguments (same as main(String[])).
      Returns:
        process exit code (0 for success)
      Since:
        6.0.0

    - #### static Path tightenStateFile(Path file)

      Restricts an existing state file to its owner when it is currently more permissive, and does nothing at all when the file is absent.

      JLine warns about an over-permissive history file rather than changing it, so as not to surprise the user. This is the one place groovysh goes further: the file records what was typed at a shell prompt, the warning is easy to miss in a log, and the directory it lives in belongs to groovysh. A mode stricter than owner-only is still left alone.

      Parameters:
        `file` - the state file
      Returns:
        the same path, for chaining