CLI Command Line
The ss-cli package provides a command-line interface for scripting common Smart SCADA operations: project initialization, device creation, data import/export, and system tasks. It is ideal for automation, CI/CD, and bulk operations that would be tedious in the UI.
1. Installation
The CLI is part of the @ss-node/ss-cli workspace package. After building the backend:
cd ss-services\ss-node
pnpm --filter @ss-node/ss-cli build
node packages/ss-cli/dist/index.js --help
For convenience, you can link it globally:
cd ss-services\ss-node\packages\ss-cli
pnpm link --global
ss-cli --help
2. Architecture
The CLI is built from:
core/ApiClient.ts— HTTP client that talks to the REST API (uses the same JWT auth)core/CommandParser.ts— parses argv into commands and optionscore/InteractivePrompts.ts— inquirer-style prompts for interactive wizardscommands/*.ts— one file per command group (device, project, alarm, collector, data, system)
Commands return structured JSON when run with --json, making them easy to chain in scripts.
3. Common Commands
3.1 Authentication
ss-cli login --url http://localhost:4000 --username admin --password admin
The CLI stores the JWT in a local credentials file (.ss-clirc) so subsequent commands do not need to re-authenticate.
3.2 Project Commands
ss-cli project list
ss-cli project create --name "Plant A" --description "Main plant"
ss-cli project delete --id <projectId>
3.3 Device Commands
ss-cli device list --project <projectId>
ss-cli device create --project <projectId> --name "RTU-01" --protocol modbus
ss-cli device create-wizard # interactive guided creation
ss-cli device ping --id <deviceId>
The device-create-wizard walks through protocol selection, connection parameters, and tag entry with prompts.
3.4 Data Commands
ss-cli data latest --device <deviceId>
ss-cli data history --device <deviceId> --start 2026-07-13T00:00:00Z --end 2026-07-13T23:59:59Z
ss-cli data export --project <projectId> --out ./export.json
ss-cli data import --project <projectId> --file ./devices.json
3.5 Collector Commands
ss-cli collector list
ss-cli collector status --protocol modbus
ss-cli collector restart --protocol modbus
3.6 Alarm Commands
ss-cli alarm list --status active
ss-cli alarm ack --id <alarmId> --comment "Acknowledged via CLI"
3.7 System Commands
ss-cli system health
ss-cli system info
ss-cli system config get --key PROJECTS_DIR
ss-cli system config set --key alarm.notification.email.enabled --value true
4. Project Initialization
A typical greenfield setup via CLI:
ss-cli login --url http://localhost:4000 --username admin --password admin
ss-cli project create --name "Demo Plant" --description "CLI-initialized project"
PROJECT_ID=$(ss-cli project list --json | jq -r '.data[0].id')
ss-cli device create --project $PROJECT_ID --name "PLC-01" --protocol modbus \
--field host=192.168.1.10 --field port=502 --field slaveId=1
ss-cli data import --project $PROJECT_ID --file ./tags.json
5. Data Import / Export
The CLI supports JSON and CSV round-trips:
data exportproduces a JSON file matching the/devices/export/jsonschemadata importaccepts the same schema, so export → edit → import is a safe workflow- For bulk tag creation, prepare a JSON array and use
device tags batchvia the API, scripted through the CLI
6. FAQ
Q: The CLI returns "unauthorized".
A: The stored token has expired. Run ss-cli login again. If the credentials file is corrupted, delete .ss-clirc and re-login.
Q: Can the CLI run against a remote server?
A: Yes. Pass --url https://your-server/api/v1 to login. Ensure the network allows the connection and that CORS is not blocking (CORS applies to browsers; the CLI is unaffected, but firewalls may still block).
Q: How do I use the CLI in a CI/CD pipeline?
A: Create a dedicated service user, store its credentials as CI secrets, run ss-cli login at the start of the job, and use --json output for parsing. Avoid using admin credentials in pipelines.
Q: Is there a way to script interactive wizards non-interactively? A: Yes — every wizard option has a corresponding CLI flag. Provide all flags explicitly and the wizard will not prompt.
7. Related Links
../../11-api/README.md../../02-project/README.md../../03-device/README.md- CLI Package