Implementation
final FigSpec jenvSpec = FigSpec(
name: "jenv",
description: "Manage your Java environment",
subcommands: [
FigSubcommand(
name: "commands",
description: "List all available JEnv commands",
),
FigSubcommand(
name: "help",
description:
"Parses and displays help contents from a command's source file",
options: [
FigOption(
name: ["--usage"],
),
],
args: [
FigArg(
name: "COMMAND",
generators: [generateAllCommands],
),
],
),
FigSubcommand(
name: "info",
description: "Show information about which command will be executed",
args: [
FigArg(
name: "command",
generators: [generateAllShims],
),
],
),
FigSubcommand(
name: "add",
description:
'Add JDK into jenv. A alias name will be generated by parsing "java -version"',
args: [
FigArg(
name: "JAVA_HOME",
template: ["folders"],
),
],
),
FigSubcommand(
name: "enable-plugin",
description: "Activate a jEnv plugin",
args: [
FigArg(
name: "pluginName",
description: "Plugin Name",
generators: [generateAllPlugins],
),
],
),
FigSubcommand(
name: "disable-plugin",
description: "Deactivate a jEnv plugin",
args: [
FigArg(
name: "pluginName",
description: "Plugin Name",
generators: [generateAllPlugins],
),
],
),
FigSubcommand(
name: "doctor",
description: "Run jEnv diagnostics",
),
FigSubcommand(
name: "exec",
description:
"Runs an executable by first preparing PATH so that the selected Java version's `bin' directory is at the front",
args: [
FigArg(
name: "command",
generators: [programGenerator],
filterStrategy: "fuzzy",
isCommand: true,
),
],
),
FigSubcommand(
name: "global",
description: "Sets the global Java version",
args: [
FigArg(
name: "version",
generators: [generateJEnvVersions],
),
],
),
FigSubcommand(
name: "global-options",
description: "Sets the global Java options",
args: [
FigArg(
name: "options",
isVariadic: true,
),
],
),
FigSubcommand(
name: "local",
description:
"Sets the local application-specific Java version by writing the version name to a file named `.java-version'",
args: [
FigArg(
name: "version",
generators: [generateJEnvVersions],
),
],
options: [
FigOption(
name: ["--unset"],
description: "Remove local jEnv settings",
),
],
),
FigSubcommand(
name: "local-options",
description: "Sets the local application-specific Java options",
args: [
FigArg(
name: "options",
isVariadic: true,
),
],
),
FigSubcommand(
name: "shell",
description:
"Sets a shell-specific Java version by setting the `JENV_VERSION'",
args: [
FigArg(
name: "version",
generators: [generateJEnvVersions],
),
],
options: [
FigOption(
name: ["--unset"],
description: "Remove shell jEnv settings",
),
],
),
FigSubcommand(
name: "shell-options",
description: "Sets the shell-specific Java options",
args: [
FigArg(
name: "options",
isVariadic: true,
),
],
),
FigSubcommand(
name: "hooks",
description: "List hook scripts for a given jenv command",
args: [
FigArg(
name: "command",
generators: [generateAllShims],
),
],
),
FigSubcommand(
name: "init",
description: "Configure the shell environment for jenv",
),
FigSubcommand(
name: "javahome",
description: "Display path to selected JAVA_HOME",
),
FigSubcommand(
name: "macos-javahome",
description:
"Installs a file located at ~/Library/LaunchAgents/jenv-environment.plist . It sets JAVA_HOME for GUI applications on startup for the **currently active version of Java**",
),
FigSubcommand(
name: "options",
description: "Show the current Java options",
),
FigSubcommand(
name: "options-file",
description: "Detect the file that sets the current jenv jvm options",
),
FigSubcommand(
name: "options-file-read",
description: "Read options from file",
args: [
FigArg(
name: "file",
template: ["filepaths"],
),
],
),
FigSubcommand(
name: "options-file-write",
description: "Write options to a file",
args: [
FigArg(
name: "file",
template: ["filepaths"],
),
FigArg(
name: "options",
isVariadic: true,
),
],
),
FigSubcommand(
name: "prefix",
description: "Displays the directory where a Java version is installed",
args: [
FigArg(
name: "version",
isOptional: true,
generators: [generateJEnvVersions],
),
],
),
FigSubcommand(
name: "refresh-plugins",
description: "Refresh plugins links",
),
FigSubcommand(
name: "refresh-versions",
description: "Refresh alias names",
),
FigSubcommand(
name: "rehash",
description: "Rehash jenv shims (run this after installing executables)",
),
FigSubcommand(
name: "remove",
description: "Remove JDK installations",
args: [
FigArg(
name: "version",
generators: [generateJEnvVersions],
),
],
),
FigSubcommand(
name: "root",
description:
"Display the root directory where versions and shims are kept",
),
FigSubcommand(
name: "shims",
description: "List existing jenv shims",
options: [
FigOption(
name: ["--short"],
description: "Show only files without path",
),
],
),
FigSubcommand(
name: "version",
description:
"Shows the currently selected Java version and how it was selected",
),
FigSubcommand(
name: "versions",
description: "Lists all Java versions found in `\$JENV_ROOT/versions/*'",
options: [
FigOption(
name: ["--bare"],
description: "Display only version",
),
FigOption(
name: ["--verbose"],
description: "Display verbose output",
),
],
),
FigSubcommand(
name: "whence",
description: "List all Java versions that contain the given executable",
options: [
FigOption(
name: ["--path"],
),
],
args: [
FigArg(
name: "command",
generators: [generateAllShims],
),
],
),
FigSubcommand(
name: "which",
description:
"Displays the full path to the executable that jenv will invoke when you run the given command",
args: [
FigArg(
name: "command",
generators: [generateAllShims],
),
],
),
],
options: [
FigOption(
name: ["--help", "-h"],
description: "Show help for jEnv",
),
FigOption(
name: ["--version"],
description: "Show version for jEnv",
),
],
);