CLI Commands
Overview
The Latte CLI provides five built-in commands (init, install, login, logout, and upgrade) plus a fallback mechanism for running build targets. The syntax is always:
$ latte [switches] <command | target>
Any argument that is not a built-in command or a flag is treated as a build target name, and Latte looks it up in the current project’s project.latte file. Running latte test invokes the test target; running latte clean jar runs clean then jar.
If a built-in command name (such as init) also exists as a target in the current project, the target takes precedence.
For global flags that apply to every invocation, see CLI Flags.
init
Initializes a new Latte project in the current directory by scaffolding it from a template. Prompts for the project group, name, and license. The template is selected by the first positional argument; with no argument the built-in library template is used.
$ latte init # library template (default)
$ latte init web # the built-in web template
$ latte init ./tmpl # a template directory on disk
Template argument
| Argument | Resolves to |
|---|---|
| (omitted) | The built-in library template. |
A bare name, e.g. web | $latte.home/templates/<name>. |
A path (contains / or \, starts with ~, or absolute) | That directory on disk. |
Prompts
| Prompt | Format |
|---|---|
| Group | Dot-separated identifier (e.g. com.example). |
| Name | Letters, digits, and hyphens (e.g. my-project). Defaults to the current directory name when it is a valid identifier. |
| License | An SPDX license identifier (e.g. Apache-2.0). Defaults to MIT if left blank. See SPDX licenses. |
init never overwrites existing files — if any target file already exists it fails and writes nothing. See Create a Project for the full guide, template variables, and the generated layout.
install
Adds a dependency to your project.latte and downloads its artifact (plus the source JAR, when available).
$ latte install <artifact-id> [version] [dependency-group]
If version is omitted, Latte queries the Latte public repository for the latest version. If dependency-group is omitted, the dependency is added to the compile group.
Examples
Install the latest version into the default compile group:
$ latte install org.apache.commons:commons-collections
Install a specific version:
$ latte install org.apache.commons:commons-collections 3.1.0
Install into a different group:
$ latte install org.testng:testng 6.8.7 test-compile
Repository lookup order is controlled by the project’s workflow block. See Workflows for details on how fetch-time repository precedence works.
login
Authenticates you with the Latte identity provider so you can publish artifacts to the Latte public repository. Login uses the OAuth 2.0 Authorization Code flow with PKCE and stores the resulting tokens in your global configuration file.
$ latte login # production IdP (auth.lattejava.org)
$ latte login http://localhost:9011 # a local IdP, for testing
Running login opens your system browser to the identity provider’s authorization page.
See Authentication for full details and Publishing for how the tokens are used.
logout
Removes the stored Latte credentials from your global configuration file. All other settings in the file are preserved.
$ latte logout
Prints You have been logged out. if you were logged in, or You are not logged in. otherwise.
upgrade
Upgrades the Latte runtime, plugins, or dependencies defined in project.latte.
$ latte upgrade <subcommand>
Subcommands
| Subcommand | Description |
|---|---|
runtime | Downloads the latest Latte release and replaces the bin, lib, and templates directories in $latte.home. No-op if already on the latest version. |
plugins | Finds every loadPlugin(...) call in project.latte, resolves the latest version of each, and rewrites the file. |
dependency <artifact-id> [version] | Upgrades a single dependency. If version is omitted, resolves the latest. |
dependencies | Resolves the latest version of every dependency in every group and rewrites project.latte. |
all | Runs runtime, plugins, and dependencies in sequence. Outside a project (no project.latte), only runtime runs; plugins and dependencies are skipped. |
help | Prints usage for the upgrade subcommands. |
Examples
Upgrade the CLI itself:
$ latte upgrade runtime
Upgrade a single dependency to its latest version:
$ latte upgrade dependency org.apache.commons:commons-collections
Upgrade everything — CLI, plugins, and dependencies — in one pass:
$ latte upgrade all
Running targets
Any argument that is not a flag is treated as a target name. If the argument is one of the built-in commands (init, install, login, logout, upgrade) and the project does not define a target of that name, Latte runs the built-in command instead (see Overview). Targets are defined in project.latte — see Targets.
$ latte clean
$ latte clean jar
$ latte test
Latte runs targets in the order they are listed on the command line and resolves each target’s dependencies using the graph defined in the project file. If a name on the command line is not a built-in command and is not a declared target, Latte exits with an error.
To see every target defined by the current project, use --listTargets.