Command reference
Each page documents a group of commands. Each command entry includes the synopsis, arguments, flags, output, and exit codes. The introduction explains the objects the commands act on.
Conventions
- A synopsis uses square brackets for an optional part and angle brackets for a value to supply. A vertical bar separates alternatives.
- A command that calls district-api accepts
--production,--staging, or--dev. Without one, the command uses the environment that the lastdistrict loginrecorded, or production. - A command that acts on a repository reads the clone in the current directory when no argument names one. The clone's
originnames the repository and the environment. - A command that waits on the network shows an indicator on stderr while it waits, when stderr is a terminal. On a terminal, the identifiers a person reads back are bold and each status has a symbol and a color. A pipe, a CI log,
NO_COLOR, and--jsonget plain bytes: no indicator, no color, and no symbols. build,deploy,app delete,repo delete,target delete, anddomain removeask a[y/N]question first.--yesanswers it. A session with no terminal cannot answer, so it needs the flag.addon deleteasks no question and requires--confirminstead, because it destroys data. Every other command acts without a question.- Exit code 0 means the command completed its documented result. Exit code 1 means the command ran and the result is a failure, or the API refused the call with its own message. Exit code 2 means the command line names nothing the command can run. The custom-domain commands also exit 3 when the certificate provider does not answer, and the addon commands exit 3 when the addon service does not answer.
Authentication
| Command | Description |
|---|---|
district login | Signs in through the browser and stores a session for one environment. |
district org list | Lists the organizations the session can act in. |
district org select | Changes the organization the session acts in. |
district whoami | Shows the stored session of each environment and checks it against district-api. |
Workspaces
| Command | Description |
|---|---|
district workspace create | Creates a workspace in the organization the session acts in. |
Repositories
| Command | Description |
|---|---|
district repo create | Creates a repository and prints its slug, id, and git remote URL. |
district repo list | Lists a workspace's repositories, most recent activity first. |
district repo clone | Clones a repository by id or by slug. |
district repo url | Prints a repository's git remote URL, for command substitution. |
district repo delete | Deletes a repository and its remote. |
Builds
| Command | Description |
|---|---|
district build | Builds a repository and follows the build to its result. |
district build attach | Follows a build that is already running. |
district build list | Lists a repository's builds, newest first. |
Apps and deployments
| Command | Description |
|---|---|
district app create | Publishes a repository as an app with one target. |
district app delete | Deletes an app with every target and custom domain it holds. |
district deploy | Builds a repository, or takes an existing build, and serves the build on one target of its app. |
Targets
| Command | Description |
|---|---|
district target list | Lists an app's targets and what each one serves. |
district target create | Adds a durable or preview target to an app. |
district target delete | Deletes a target that is not the primary one. |
district target set-primary | Makes a durable target the app's primary target. |
district target set-deployment | Points a target at a deployment of its environment. |
district target set-env | Changes the environment of a durable target that is not primary. |
Custom domains
| Command | Description |
|---|---|
district domain add | Attaches a custom domain to one target and prints the DNS records to publish. |
district domain list | Lists an app's custom domains and the state of each one. |
district domain status | Shows a custom domain's state, certificate expiry, and DNS records. |
district domain verify | Checks a custom domain now and exits non-zero until it serves the app. |
district domain remove | Removes a custom domain from an app. |
Addons
| Command | Description |
|---|---|
district addon create | Creates a D1 database, an R2 bucket or a KV namespace, and waits for it. |
district addon list | Lists a workspace's addons, newest first. |
district addon show | Shows an addon's state, alias, last error, and the apps that bind it. |
district addon rename | Changes an addon's display name. Its id and alias do not change. |
district addon delete | Deletes an addon and destroys its data. Requires --confirm. |
Git credential helper
| Command | Description |
|---|---|
district git-credential install | Registers the helper in the global git configuration. |
district git-credential status | Reports whether the registered helper can run and authenticate. |
district git-credential get | Issues or reuses a short-lived repository token. Git calls it; people do not. |
Settings and storage
| Command | Description |
|---|---|
district settings companion | Chooses the companion that appears in command output. |