- Add Cobra-based CLI with ums init, ums serve, ums version commands - ums init supports interactive prompts and non-interactive flags - Generates secure JWT secrets and config.yaml automatically - Extract server.Serve() function for reuse - Add cross-platform build targets to Makefile - Update README with CLI installation and usage instructions New files: - cmd/ums/main.go - CLI entry point - cmd/ums/cmd/root.go - Root command - cmd/ums/cmd/init.go - Interactive/non-interactive init - cmd/ums/cmd/serve.go - Server command - cmd/ums/cmd/version.go - Version command - internal/server/server.go - Extracted Serve function
32 lines
713 B
Go
32 lines
713 B
Go
package cmd
|
|
|
|
import (
|
|
"fmt"
|
|
"runtime"
|
|
|
|
"github.com/spf13/cobra"
|
|
)
|
|
|
|
var (
|
|
Version = "1.0.0"
|
|
Commit = "dev"
|
|
BuildDate = "unknown"
|
|
)
|
|
|
|
func newVersionCmd() *cobra.Command {
|
|
return &cobra.Command{
|
|
Use: "version",
|
|
Short: "Print version information",
|
|
Long: `Print the UMS version, Go version, and build information`,
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
fmt.Printf("UMS CLI - User Management System\n")
|
|
fmt.Printf("Version: %s\n", Version)
|
|
fmt.Printf("Commit: %s\n", Commit)
|
|
fmt.Printf("Build Date: %s\n", BuildDate)
|
|
fmt.Printf("Go Version: %s\n", runtime.Version())
|
|
fmt.Printf("OS/Arch: %s/%s\n", runtime.GOOS, runtime.GOARCH)
|
|
return nil
|
|
},
|
|
}
|
|
}
|