feat(tpagectl): establish configuration management #537
No reviewers
Labels
No labels
Compat/Breaking
Kind/Bug
Kind/Documentation
Kind/Enhancement
Kind/Feature
Kind/Security
Kind/Testing
Priority
Critical
Priority
High
Priority
Low
Priority
Medium
Reviewed
Confirmed
Reviewed
Duplicate
Reviewed
Invalid
Reviewed
Won't Fix
Status
Abandoned
Status
Blocked
Status
Need More Info
No milestone
No project
No assignees
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
thwap/thwap-pagesd!537
Loading…
Reference in a new issue
No description provided.
Delete branch "feat/cli-config"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Adds the configuration system for the tpagectl CLI client, covering config struct definition, file lookup, environment variables, flag overrides, and the
--configflag.internal/tpagectl/configpackage with aConfig{Server: {URL, Token}}struct and a viper-basedLoadmirroring the daemon's pattern..tpagectl.{yaml,json}file (.,$XDG_CONFIG_HOME/tpagectl,/etc/tpagectl) →TPAGECTL_*environment variables → command-line flags.--config,--server, and--tokenflags; aBeforehook loads config and applies flag overrides only when explicitly set, stashing the result in context for future subcommands.Why
Phase 1 roadmap task #155. The CLI needs a config layer before HTTP client and command work (Phases 2+) can consume server URL and auth token.
Testing
--configfile and missing-file errorgo test -race ./...passesgolangci-lint runcleanBreaking Changes
None.
Notes
Reuses the existing
github.com/spf13/viperdependency — no new modules. Env is handled inconfig.Loadvia viper, not at the flag level, soIsSetstays true only for explicit CLI flags.Closes #150
Closes #151
Closes #152
Closes #153
Closes #154
Closes #155
Record completion of the tpagectl configuration system: client config struct, .tpagectl.{yaml,json} lookup, TPAGECTL_* environment variables, flag overrides, and the --config flag. closes #150 closes #151 closes #152 closes #153 closes #154 closes #155Summary
Configuration system for tpagectl. Verified:
go test -race ./...passes (including newcmd/tpagectlandinternal/tpagectl/configpackages) andgolangci-lint run ./...is clean. Pattern mirrors the daemon'sinternal/configclosely. Closes #150-155.No blocking issues.
Suggestions (filed as issues)
cmd/tpagectl/main.go:79–configFromContextreturns nil without an error signal; future subcommands risk nil dereference. Filed as #538cmd/tpagectl/main.go:55–--tokenflag exposes the API token via argv (ps/shell history);TPAGECTL_SERVER_TOKENenv is the safer path. Filed as #539internal/tpagectl/config/config.go:60–SetConfigName(".tpagectl")auto-discovers all viper extensions, not just documented yaml/json; extension order is nondeterministic when multiple files exist. Filed as #540cmd/tpagectl/main_test.go– precedence chain tested for defaults/file/env/flag>env but not flag>file. Filed as #541Praise