Files
kvs-sh/main.go
ryyst 33201227ca feat: add group management commands
Implemented roadmap #5: Group management commands with full CRUD.

Features:
- group create <name> [members] - Create new group with optional initial members
- group get <uuid> - Display group details (uuid, name_hash, members, timestamps)
- group update <uuid> <members> - Replace entire member list
- group delete <uuid> - Delete group
- group add-member <uuid> <user-uuid> - Add single member (incremental)
- group remove-member <uuid> <user-uuid> - Remove single member (incremental)

The add-member and remove-member commands fetch current members, modify the list,
and update atomically - providing a better UX than replacing the entire list.

Backend API endpoints used:
- POST /api/groups - Create group
- GET /api/groups/{uuid} - Get group details
- PUT /api/groups/{uuid} - Update members
- DELETE /api/groups/{uuid} - Delete group

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-05 23:50:27 +03:00

106 lines
2.0 KiB
Go

package main
import (
"fmt"
"os"
"strings"
"github.com/chzyer/readline"
)
func main() {
client := NewKVSClient("http://localhost:8090")
// Load saved profiles
if config, err := LoadConfig(); err == nil {
client.syncConfigToClient(config)
}
// Setup readline
rl, err := readline.NewEx(&readline.Config{
Prompt: cyan("kvs> "),
HistoryFile: os.Getenv("HOME") + "/.kvs_history",
AutoComplete: completer,
InterruptPrompt: "^C",
EOFPrompt: "exit",
})
if err != nil {
panic(err)
}
defer rl.Close()
fmt.Println(magenta("KVS Interactive Shell"))
fmt.Println("Type 'help' for available commands")
if client.activeProfile != "" {
fmt.Println(green("Active profile:"), client.activeProfile)
}
fmt.Println()
for {
line, err := rl.Readline()
if err != nil {
break
}
line = strings.TrimSpace(line)
if line == "" {
continue
}
parts := parseCommand(line)
if len(parts) == 0 {
continue
}
cmd := parts[0]
args := parts[1:]
switch cmd {
case "exit", "quit":
fmt.Println("Goodbye!")
return
case "clear":
print("\033[H\033[2J")
case "help":
client.handleHelp(args)
case "connect":
client.handleConnect(args)
case "auth":
client.handleAuth(args)
case "profile":
client.handleProfile(args)
case "get":
client.handleGet(args)
case "put":
client.handlePut(args)
case "delete":
client.handleDelete(args)
case "meta":
client.handleMeta(args)
case "members":
client.handleMembers(args)
case "health":
client.handleHealth(args)
case "user":
if len(args) > 0 {
switch args[0] {
case "get":
client.handleUserGet(args[1:])
case "create":
client.handleUserCreate(args[1:])
default:
fmt.Println(red("Unknown user command:"), args[0])
fmt.Println("Type 'help' for available commands")
}
} else {
client.handleUserList(args)
}
case "group":
client.handleGroup(args)
default:
fmt.Println(red("Unknown command:"), cmd)
fmt.Println("Type 'help' for available commands")
}
}
}