nika-cli app
Inspect and configure the apps in a project. Aliases: nika-cli apps,
nika-cli workspace.
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.
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:
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.
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/.
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, andworkspace.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, orapp, and otherwise the first alphabetically; - points the root
[build] cmdat 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:
- the
-a/--appflag - the
NIKA_APPenvironment variable - the only app, when there is one
workspace.default_app(fornika-cli start)- an interactive prompt
See also
- Workspaces - layout detection and the microservice model.
- Configuration - the
[workspace]and[apps.*]sections. nika-cli start- running one service.nika-cli generate- generating into one service.