diff options
| author | Paul Buetow <paul@buetow.org> | 2026-02-22 09:28:52 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-02-22 09:28:52 +0200 |
| commit | 7ae8855a075773c50ab8db8ee65bbfa9710f140e (patch) | |
| tree | 590496d0883dfeb928e660345325e9a725688b79 /Magefile.go | |
| parent | dc2d267244d6dd9d991207fe193e987b6477c415 (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'Magefile.go')
| -rw-r--r-- | Magefile.go | 59 |
1 files changed, 59 insertions, 0 deletions
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) +} |
