From 8c6ab6dc83e56bb2e95a08dc5b5598589f6f97b1 Mon Sep 17 00:00:00 2001 From: Steven Tracey Date: Wed, 6 May 2026 20:10:11 -0500 Subject: [PATCH] [CI-SKIP] Stash Claude Edits --- app/commands.go | 2 +- app/server/main.go | 33 +++++++++++++++++++++++++++++++-- server/git.go | 16 ++++++++-------- 3 files changed, 40 insertions(+), 11 deletions(-) diff --git a/app/commands.go b/app/commands.go index eb26be6..92bcb0c 100644 --- a/app/commands.go +++ b/app/commands.go @@ -79,7 +79,7 @@ func newKeyCmd(cmd *cobra.Command, args []string) { if err != nil { log.Fatalf("%v", err) } - fmt.Printf(key) + fmt.Println(key) } func newDomainCmd(domain, domainDir string, dirOverridden bool) error { diff --git a/app/server/main.go b/app/server/main.go index f7d1436..32686c0 100644 --- a/app/server/main.go +++ b/app/server/main.go @@ -1,7 +1,36 @@ package main -import "fmt" +import ( + "fmt" + "os" + + "git.nevets.tech/Steven/certman/app" + "github.com/spf13/cobra" +) func main() { - fmt.Println("Hello server") + rootCmd := &cobra.Command{ + Use: "certman", + Short: "CertMan", + Long: "Certificate Manager", + RunE: func(cmd *cobra.Command, args []string) error { + return cmd.Help() + }, + } + + rootCmd.AddCommand(app.VersionCmd) + rootCmd.AddCommand(app.NewKeyCmd) + rootCmd.AddCommand(app.DevCmd) + + rootCmd.AddCommand(app.NewDomainCmd) + rootCmd.AddCommand(app.InstallCmd) + + rootCmd.AddCommand(app.CertCmd) + + rootCmd.AddCommand(app.DaemonCmd) + + if err := rootCmd.Execute(); err != nil { + fmt.Fprintln(os.Stderr, err) + os.Exit(1) + } } diff --git a/server/git.go b/server/git.go index 79283b4..dd12201 100644 --- a/server/git.go +++ b/server/git.go @@ -66,12 +66,12 @@ func VerifyOwnership(ws *common.GitWorkspace, uuid string) (bool, error) { return false, fmt.Errorf("domain is owned by server %q", existing) } -// AddAndPushCerts stages every *.crpt file from dataRoot into the workspace, +// AddAndPushCerts stages every *.crpt file from certsDir into the workspace, // (re-)writes SERVER_ID with config.App.UUID, commits any resulting change, // and pushes to origin/. If nothing changed the call is a no-op // and returns nil without pushing. -func AddAndPushCerts(ws *common.GitWorkspace, dataRoot string, config *common.AppConfig) error { - if err := stageCerts(ws, dataRoot); err != nil { +func AddAndPushCerts(ws *common.GitWorkspace, certsDir string, config *common.AppConfig) error { + if err := stageCerts(ws, certsDir); err != nil { return err } if err := stageFile(ws, serverIDFile, []byte(config.App.UUID)); err != nil { @@ -111,19 +111,19 @@ func AddAndPushCerts(ws *common.GitWorkspace, dataRoot string, config *common.Ap return nil } -// stageCerts copies every *.crpt file in dataRoot into the workspace +// stageCerts copies every *.crpt file in certsDir into the workspace // filesystem and adds it to the work tree. -func stageCerts(ws *common.GitWorkspace, dataRoot string) error { - entries, err := os.ReadDir(dataRoot) +func stageCerts(ws *common.GitWorkspace, certsDir string) error { + entries, err := os.ReadDir(certsDir) if err != nil { - return fmt.Errorf("read %s: %w", dataRoot, err) + return fmt.Errorf("read %s: %w", certsDir, err) } for _, entry := range entries { name := entry.Name() if !strings.HasSuffix(name, ".crpt") { continue } - body, err := os.ReadFile(filepath.Join(dataRoot, name)) + body, err := os.ReadFile(filepath.Join(certsDir, name)) if err != nil { return fmt.Errorf("read %s: %w", name, err) }