From 7ae8855a075773c50ab8db8ee65bbfa9710f140e Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sun, 22 Feb 2026 09:28:52 +0200 Subject: Add Go project scaffold (task 352) - go.mod with module codeberg.org/snonux/geheim (go 1.22, mage dep) - Magefile.go with Build, Test, Install, Uninstall targets - cmd/geheim/main.go delegating to internal/cli - Stub packages: cli, version, config, crypto, git, store, clipboard, shell - go.sum generated; binary confirmed to build via mage build Co-Authored-By: Claude Sonnet 4.6 --- Magefile.go | 59 +++++++++++++++++++++++++++++++++++++++++ cmd/geheim/main.go | 13 +++++++++ go.mod | 5 ++++ go.sum | 2 ++ internal/cli/cli.go | 9 +++++++ internal/clipboard/clipboard.go | 2 ++ internal/config/config.go | 5 ++++ internal/crypto/crypto.go | 2 ++ internal/git/git.go | 2 ++ internal/shell/shell.go | 2 ++ internal/store/data.go | 2 ++ internal/store/index.go | 2 ++ internal/store/store.go | 2 ++ internal/version/version.go | 5 ++++ 14 files changed, 112 insertions(+) create mode 100644 Magefile.go create mode 100644 cmd/geheim/main.go create mode 100644 go.mod create mode 100644 go.sum create mode 100644 internal/cli/cli.go create mode 100644 internal/clipboard/clipboard.go create mode 100644 internal/config/config.go create mode 100644 internal/crypto/crypto.go create mode 100644 internal/git/git.go create mode 100644 internal/shell/shell.go create mode 100644 internal/store/data.go create mode 100644 internal/store/index.go create mode 100644 internal/store/store.go create mode 100644 internal/version/version.go diff --git a/Magefile.go b/Magefile.go new file mode 100644 index 0000000..ee80721 --- /dev/null +++ b/Magefile.go @@ -0,0 +1,59 @@ +//go:build mage + +// Magefile provides build targets for the geheim project. +// Targets: Build, Test, Install, Uninstall +package main + +import ( + "fmt" + "os" + + "github.com/magefile/mage/mg" + "github.com/magefile/mage/sh" +) + +const ( + binary = "./bin/geheim" + mainPkg = "./cmd/geheim" +) + +// Build compiles the binary to ./bin/geheim. +func Build() error { + mg.Deps(createBinDir) + fmt.Println("Building", binary) + return sh.RunV("go", "build", "-o", binary, mainPkg) +} + +// Test runs all tests in the module. +func Test() error { + fmt.Println("Running tests") + return sh.RunV("go", "test", "./...") +} + +// Install builds the binary and copies it to ~/.local/bin/geheim. +func Install() error { + mg.Deps(Build) + home, err := os.UserHomeDir() + if err != nil { + return fmt.Errorf("cannot determine home directory: %w", err) + } + dest := home + "/.local/bin/geheim" + fmt.Println("Installing to", dest) + return sh.Copy(dest, binary) +} + +// Uninstall removes the installed binary from ~/.local/bin/geheim. +func Uninstall() error { + home, err := os.UserHomeDir() + if err != nil { + return fmt.Errorf("cannot determine home directory: %w", err) + } + dest := home + "/.local/bin/geheim" + fmt.Println("Uninstalling", dest) + return os.Remove(dest) +} + +// createBinDir ensures ./bin exists before the build step writes the binary. +func createBinDir() error { + return os.MkdirAll("./bin", 0755) +} diff --git a/cmd/geheim/main.go b/cmd/geheim/main.go new file mode 100644 index 0000000..4032f53 --- /dev/null +++ b/cmd/geheim/main.go @@ -0,0 +1,13 @@ +// main is the entry point for the geheim binary. +// It delegates all logic to the cli package and exits with the returned code. +package main + +import ( + "os" + + "codeberg.org/snonux/geheim/internal/cli" +) + +func main() { + os.Exit(cli.Run()) +} diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..a8bd639 --- /dev/null +++ b/go.mod @@ -0,0 +1,5 @@ +module codeberg.org/snonux/geheim + +go 1.22 + +require github.com/magefile/mage v1.15.0 diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..4ee1b87 --- /dev/null +++ b/go.sum @@ -0,0 +1,2 @@ +github.com/magefile/mage v1.15.0 h1:BvGheCMAsG3bWUDbZ8AyXXpCNwU9u5CB6sM+HNb9HYg= +github.com/magefile/mage v1.15.0/go.mod h1:z5UZb/iS3GoOSn0JgWuiw7dxlurVYTu+/jHXqQg881A= diff --git a/internal/cli/cli.go b/internal/cli/cli.go new file mode 100644 index 0000000..4b4e8c5 --- /dev/null +++ b/internal/cli/cli.go @@ -0,0 +1,9 @@ +// Package cli implements the command-line interface for geheim. +// Run() is called by main and returns an exit code. +package cli + +// Run is the top-level entry point for the CLI. +// Returns 0 on success, non-zero on error. +func Run() int { + return 0 +} diff --git a/internal/clipboard/clipboard.go b/internal/clipboard/clipboard.go new file mode 100644 index 0000000..6635537 --- /dev/null +++ b/internal/clipboard/clipboard.go @@ -0,0 +1,2 @@ +// Package clipboard provides clipboard read/write access for geheim. +package clipboard diff --git a/internal/config/config.go b/internal/config/config.go new file mode 100644 index 0000000..3474b73 --- /dev/null +++ b/internal/config/config.go @@ -0,0 +1,5 @@ +// Package config handles loading and storing geheim configuration. +package config + +// Config holds application-wide configuration values. +type Config struct{} diff --git a/internal/crypto/crypto.go b/internal/crypto/crypto.go new file mode 100644 index 0000000..0e985f4 --- /dev/null +++ b/internal/crypto/crypto.go @@ -0,0 +1,2 @@ +// Package crypto provides encryption and decryption primitives for geheim. +package crypto diff --git a/internal/git/git.go b/internal/git/git.go new file mode 100644 index 0000000..6d29fda --- /dev/null +++ b/internal/git/git.go @@ -0,0 +1,2 @@ +// Package git wraps git operations used by geheim to manage the secret store. +package git diff --git a/internal/shell/shell.go b/internal/shell/shell.go new file mode 100644 index 0000000..2c8739b --- /dev/null +++ b/internal/shell/shell.go @@ -0,0 +1,2 @@ +// Package shell provides interactive shell and readline integration for geheim. +package shell diff --git a/internal/store/data.go b/internal/store/data.go new file mode 100644 index 0000000..fb5547d --- /dev/null +++ b/internal/store/data.go @@ -0,0 +1,2 @@ +// data.go handles reading and writing individual secret data blobs. +package store diff --git a/internal/store/index.go b/internal/store/index.go new file mode 100644 index 0000000..cd80dc5 --- /dev/null +++ b/internal/store/index.go @@ -0,0 +1,2 @@ +// index.go manages the index of entries within the secret store. +package store diff --git a/internal/store/store.go b/internal/store/store.go new file mode 100644 index 0000000..3ebde40 --- /dev/null +++ b/internal/store/store.go @@ -0,0 +1,2 @@ +// Package store manages the geheim secret store on disk. +package store diff --git a/internal/version/version.go b/internal/version/version.go new file mode 100644 index 0000000..c7defb0 --- /dev/null +++ b/internal/version/version.go @@ -0,0 +1,5 @@ +// Package version holds the application version string. +package version + +// Version is the current release version of geheim. +const Version = "0.0.0" -- cgit v1.2.3