Summary
The CLI client commands (repos, search, jobs) read --api-url and --timeout directly from cobra flags, bypassing Viper entirely. This means:
CODECHUNK_CLIENT_API_URL and CODECHUNK_CLIENT_TIMEOUT env vars are never picked up by commands (only by client.LoadConfig(), which is never called from any command handler)
- No config file support for client settings
- Every invocation requires explicit flags or relies on hardcoded defaults
Proposed Fix
-
internal/client/commands/root.go — add Viper setup in NewRootCmd:
- Bind
--api-url persistent flag → client.api_url
- Bind
--timeout persistent flag → client.timeout
- Bind env vars
CODECHUNK_CLIENT_API_URL and CODECHUNK_CLIENT_TIMEOUT
-
internal/client/commands/repos.go — update createClientFromFlags to read through Viper (viper.GetString / viper.GetDuration) instead of raw cobra flag access
Priority order (flag wins, then env var, then default)
--api-url flag > CODECHUNK_CLIENT_API_URL > http://localhost:8080
--timeout flag > CODECHUNK_CLIENT_TIMEOUT > 30s
Affected commands
All client subcommands share createClientFromFlags, so this fix covers:
repos list, repos get, repos add, repos delete, repos jobs, repos query
search
jobs get
health
Summary
The CLI client commands (
repos,search,jobs) read--api-urland--timeoutdirectly from cobra flags, bypassing Viper entirely. This means:CODECHUNK_CLIENT_API_URLandCODECHUNK_CLIENT_TIMEOUTenv vars are never picked up by commands (only byclient.LoadConfig(), which is never called from any command handler)Proposed Fix
internal/client/commands/root.go— add Viper setup inNewRootCmd:--api-urlpersistent flag →client.api_url--timeoutpersistent flag →client.timeoutCODECHUNK_CLIENT_API_URLandCODECHUNK_CLIENT_TIMEOUTinternal/client/commands/repos.go— updatecreateClientFromFlagsto read through Viper (viper.GetString/viper.GetDuration) instead of raw cobra flag accessPriority order (flag wins, then env var, then default)
Affected commands
All client subcommands share
createClientFromFlags, so this fix covers:repos list,repos get,repos add,repos delete,repos jobs,repos querysearchjobs gethealth