Skip to content

nika-cli app

Inspect and configure the apps in a project. Aliases: nika-cli apps, nika-cli workspace.

nika-cli app list
nika-cli app use <name>
nika-cli app sync

The layout itself is detected from disk, so these commands are for looking at what was found and choosing the default service — not for declaring the structure. See Workspaces for how detection works.

nika-cli app list

Print every app with its source folder, run command, and the modules it already contains.

nika-cli app list
Microservice workspace — module nikaapp

 * api              src: apps/api/src             run: go run ./apps/api/main.go
                    modules: [user-grpc user-redis user-tcp]
   micro-grpc       src: apps/micro-grpc/src      run: go run ./apps/micro-grpc/main.go
                    modules: [user]

 * = default for `nika-cli start` (change it with `nika-cli app use <name>`)

In a single-application project the same command reports one app:

Single application — module nikaapp

   app              src: src                      run: go run .
                    modules: [common user]

nika-cli app use

Set the app that nika-cli start runs when no -a flag is given. This writes workspace.default_app and points build.cmd at that service.

nika-cli app use api
Default app is now "api" (go run ./apps/api/main.go)

Partial names work when unambiguous: nika-cli app use grpc resolves to micro-grpc.

nika-cli app sync

Rewrite .nika.toml to match what is on disk. Run it after adding or removing a service under apps/.

nika-cli app sync
Updated .nika.toml: 4 app(s) — [api micro-grpc micro-redis micro-tcp]
Default app: api → go run ./apps/api/main.go

Sync:

  • records workspace.mode, workspace.apps, and workspace.apps_dir;
  • gives every service an [apps.<name>] entry with a run command, leaving any command you customised alone;
  • drops [apps.*] entries for services that no longer exist;
  • picks a default app if none is set, preferring a gateway named api, gateway, http, web, or app, and otherwise the first alphabetically;
  • points the root [build] cmd at the default app.

That last step is why sync matters: without it, [build] cmd in a workspace usually still reads go run ., and the project root has no main package to run.

nika-cli generate runs sync automatically in a workspace, so in practice you only need it after restructuring by hand.

Choosing the target for one command

Precedence, highest first:

  1. the -a / --app flag
  2. the NIKA_APP environment variable
  3. the only app, when there is one
  4. workspace.default_app (for nika-cli start)
  5. an interactive prompt
nika-cli g res user -a api
NIKA_APP=micro-grpc nika-cli g res order

See also