Files
kvs-sh/cmd_system.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

70 lines
2.1 KiB
Go

package main
import "fmt"
func (c *KVSClient) handleConnect(args []string) {
if len(args) < 1 {
fmt.Println(red("Usage: connect <base-url>"))
return
}
c.baseURL = args[0]
fmt.Println(green("Connected to:"), c.baseURL)
}
func (c *KVSClient) handleAuth(args []string) {
if len(args) < 1 {
fmt.Println(red("Usage: auth <token>"))
return
}
c.currentToken = args[0]
fmt.Println(green("Authentication token set"))
}
func (c *KVSClient) handleHelp(args []string) {
help := `
KVS Interactive Shell - Available Commands:
Connection & Authentication:
connect <url> - Connect to KVS server
auth <token> - Set authentication token
profile - List all profiles
profile add <name> <token> <user-uuid> [url] - Add user profile
profile use <name> - Switch to user profile
profile remove <name> - Remove user profile
profile save - Save profiles to ~/.kvs/config.json
profile load - Load profiles from ~/.kvs/config.json
Key-Value Operations:
get <key> - Retrieve value for key
put <key> <json> - Store JSON value at key
delete <key> - Delete key
Resource Metadata:
meta get <key> - Get metadata (owner, group) for a key
meta set <key> [flags] - Set metadata for a key
Flags: --owner <uuid>, --group <uuid>, --permissions <number>
Cluster Management:
members - List cluster members
health - Check service health
User Management:
user get <uuid> - Get user details
user create <nickname> - Create new user (admin only)
Group Management:
group create <name> [members] - Create new group
group get <uuid> - Get group details
group update <uuid> <members> - Replace all group members
group delete <uuid> - Delete group
group add-member <uuid> <user-uuid> - Add member to group
group remove-member <uuid> <user-uuid> - Remove member from group
System:
help - Show this help
exit, quit - Exit shell
clear - Clear screen
`
fmt.Println(help)
}