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 last district login recorded, or production.
  • A command that acts on a repository reads the clone in the current directory when no argument names one. The clone's origin names 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 --json get plain bytes: no indicator, no color, and no symbols.
  • build, deploy, app delete, repo delete, target delete, and domain remove ask a [y/N] question first. --yes answers it. A session with no terminal cannot answer, so it needs the flag. addon delete asks no question and requires --confirm instead, 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

CommandDescription
district loginSigns in through the browser and stores a session for one environment.
district org listLists the organizations the session can act in.
district org selectChanges the organization the session acts in.
district whoamiShows the stored session of each environment and checks it against district-api.

Workspaces

CommandDescription
district workspace createCreates a workspace in the organization the session acts in.

Repositories

CommandDescription
district repo createCreates a repository and prints its slug, id, and git remote URL.
district repo listLists a workspace's repositories, most recent activity first.
district repo cloneClones a repository by id or by slug.
district repo urlPrints a repository's git remote URL, for command substitution.
district repo deleteDeletes a repository and its remote.

Builds

CommandDescription
district buildBuilds a repository and follows the build to its result.
district build attachFollows a build that is already running.
district build listLists a repository's builds, newest first.

Apps and deployments

CommandDescription
district app createPublishes a repository as an app with one target.
district app deleteDeletes an app with every target and custom domain it holds.
district deployBuilds a repository, or takes an existing build, and serves the build on one target of its app.

Targets

CommandDescription
district target listLists an app's targets and what each one serves.
district target createAdds a durable or preview target to an app.
district target deleteDeletes a target that is not the primary one.
district target set-primaryMakes a durable target the app's primary target.
district target set-deploymentPoints a target at a deployment of its environment.
district target set-envChanges the environment of a durable target that is not primary.

Custom domains

CommandDescription
district domain addAttaches a custom domain to one target and prints the DNS records to publish.
district domain listLists an app's custom domains and the state of each one.
district domain statusShows a custom domain's state, certificate expiry, and DNS records.
district domain verifyChecks a custom domain now and exits non-zero until it serves the app.
district domain removeRemoves a custom domain from an app.

Addons

CommandDescription
district addon createCreates a D1 database, an R2 bucket or a KV namespace, and waits for it.
district addon listLists a workspace's addons, newest first.
district addon showShows an addon's state, alias, last error, and the apps that bind it.
district addon renameChanges an addon's display name. Its id and alias do not change.
district addon deleteDeletes an addon and destroys its data. Requires --confirm.

Git credential helper

CommandDescription
district git-credential installRegisters the helper in the global git configuration.
district git-credential statusReports whether the registered helper can run and authenticate.
district git-credential getIssues or reuses a short-lived repository token. Git calls it; people do not.

Settings and storage

CommandDescription
district settings companionChooses the companion that appears in command output.