feat: add persistent profile storage to ~/.kvs/config.json
Implemented roadmap #1: Configuration file for persistent profiles. Features: - Auto-saves profiles to ~/.kvs/config.json on add/use/remove - Auto-loads profiles on shell startup - File created with 0600 permissions for token security - Shows active profile in welcome message - Added 'profile save' and 'profile load' commands for manual control Technical details: - Created config.go with LoadConfig/SaveConfig functions - Profile changes automatically trigger persistence - ~/.kvs directory created with 0700 permissions if missing - Gracefully handles missing config file on first run 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -38,6 +38,7 @@ func (c *KVSClient) handleProfile(args []string) {
|
||||
BaseURL: baseURL,
|
||||
}
|
||||
fmt.Println(green("Profile added:"), args[1])
|
||||
c.saveProfiles()
|
||||
|
||||
case "use":
|
||||
if len(args) < 2 {
|
||||
@@ -54,6 +55,7 @@ func (c *KVSClient) handleProfile(args []string) {
|
||||
c.baseURL = profile.BaseURL
|
||||
c.activeProfile = args[1]
|
||||
fmt.Println(green("Switched to profile:"), args[1])
|
||||
c.saveProfiles()
|
||||
|
||||
case "remove":
|
||||
if len(args) < 2 {
|
||||
@@ -65,5 +67,29 @@ func (c *KVSClient) handleProfile(args []string) {
|
||||
c.activeProfile = ""
|
||||
}
|
||||
fmt.Println(green("Profile removed:"), args[1])
|
||||
c.saveProfiles()
|
||||
|
||||
case "save":
|
||||
if err := c.saveProfiles(); err != nil {
|
||||
fmt.Println(red("Error saving profiles:"), err)
|
||||
return
|
||||
}
|
||||
fmt.Println(green("Profiles saved to ~/.kvs/config.json"))
|
||||
|
||||
case "load":
|
||||
config, err := LoadConfig()
|
||||
if err != nil {
|
||||
fmt.Println(red("Error loading profiles:"), err)
|
||||
return
|
||||
}
|
||||
c.syncConfigToClient(config)
|
||||
fmt.Println(green("Profiles loaded from ~/.kvs/config.json"))
|
||||
if c.activeProfile != "" {
|
||||
fmt.Println(cyan("Active profile:"), c.activeProfile)
|
||||
}
|
||||
|
||||
default:
|
||||
fmt.Println(red("Unknown profile command:"), subCmd)
|
||||
fmt.Println("Available commands: add, use, remove, save, load")
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user