refactor: split monolithic main.go into modular structure

Refactored 800+ line main.go into clean, domain-separated files:
- main.go (96 lines) - Entry point and command router only
- types.go - Type definitions and data structures
- client.go - HTTP client and request handling
- cmd_kv.go - Key-value operations (get/put/delete)
- cmd_meta.go - Resource metadata commands
- cmd_user.go - User management commands
- cmd_profile.go - Profile management
- cmd_cluster.go - Cluster operations (members/health)
- cmd_system.go - System commands (connect/auth/help)
- utils.go - Shared utilities (parsing, colors, completion)

No functional changes, pure reorganization for maintainability.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-10-05 23:34:18 +03:00
parent fcd27dee97
commit 0c9e314d7c
10 changed files with 764 additions and 710 deletions

59
cmd_system.go Normal file
View File

@@ -0,0 +1,59 @@
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 add <name> <token> <user-uuid> [url] - Add user profile
profile use <name> - Switch to user profile
profile remove <name> - Remove user profile
profile - List all profiles
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)
System:
help - Show this help
exit, quit - Exit shell
clear - Clear screen
`
fmt.Println(help)
}