GitHub
09/25/2026, 7:53 PMosctrl-cli without a valid API configuration just failed:
• Missing/unreadable --api-file (default osctrl-api.json) → hard LoadConfiguration error
• Empty URL or token → CreateAPI failure
Nothing guided the operator to a working setup.
Changes
New: cmd/cli/api_prompt.go
• missingAPIConfiguration — reports whether URL or token are still absent
• promptMissingAPIConfiguration — asks only for what's missing:
• URL: plain-text prompt, re-asks on empty input
• Token: hidden input via term.ReadPassword, re-asks on empty
• Values already resolved (flag, `API_URL`/`API_TOKEN` env, config file) are kept and not re-asked
• Non-interactive stdin (pipes, scripts, CI) never blocks — fails with actionable guidance naming exactly what's missing and all supported sources (--api-file, `--api-url`/`--api-token`, env vars, or run interactively)
Wired: cmd/cli/main.go
• cliWrapper API path — every API-backed command now falls back to the prompt
• check-api — same fallback
• Unreadable config file logs the reason in debug and falls through to prompting instead of aborting
Unchanged
• `login`'s own flow (only needs a URL, then mints its own token)
• Explicit --db / DB-file paths
Behavior Example
$ osctrl-cli node list
No osctrl API configuration found. Please provide the connection details.
-> API URL: https://osctrl.example.com
-> API token: ********
...
Validation
| Check | Result |
| ----------------------------------- | ---------- |
| go build ./... | ✅ |
| go test ./cmd/cli/ ./pkg/apiclient/ | ✅ |
| golangci-lint ./cmd/cli/... | ✅ 0 issues |
| gofmt | ✅ clean |
Tests Added
• cmd/cli/api_prompt_test.go — completeness detection (URL/token/both/none) and non-interactive fallback errors (partial configs keep their values; error names what's missing)
jmpsec/osctrlGitHub
09/25/2026, 8:06 PM