diff options
| author | Paul Buetow <paul@buetow.org> | 2026-06-11 00:18:01 +0300 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-06-11 00:18:01 +0300 |
| commit | 1f3ae20a9830fd776f6ef3c11b4c198154b8205f (patch) | |
| tree | d89a9cc312fe6f783d88bf2b1726d948e70486c8 | |
| parent | 236f6543b093e54157f40ec0c021b35177e1713e (diff) | |
Magefile: convert Default to a function and add binaryName constant
Convert the Default target from a `Default = Build` variable to a
documented `Default()` function (Mage supports both forms), and
introduce a binaryName constant for the primary hexai binary so the
output name is defined once instead of being repeated across the
Build, Dev, and Install targets.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
| -rw-r--r-- | Magefile.go | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/Magefile.go b/Magefile.go index b1393be..30e8caf 100644 --- a/Magefile.go +++ b/Magefile.go @@ -17,12 +17,25 @@ import ( "github.com/magefile/mage/sh" ) +// binaryName is the name of the project's primary CLI binary. It is also used +// as the build output name for the main hexai command so that the literal is +// defined in a single place instead of being repeated across targets. +const binaryName = "hexai" + var ( - Default = Build // Default target: build all binaries. coverageThreshold float64 = 80 coveragePrinted = make(chan struct{}, 1) ) +// Default is the default Mage target (runs when `mage` is invoked without a +// target). It is declared as a function rather than a `Default = Build` +// variable so that it can carry documentation and any future setup logic; Mage +// supports both forms but the function form keeps the target consistent with +// the other documented targets in this file. +func Default() error { + return Build() +} + // Build builds binaries. func Build() error { printCoverage() @@ -45,7 +58,7 @@ func BuildHexaiLSP() error { // BuildHexaiCLI builds the CLI binary. func BuildHexaiCLI() error { printCoverage() - return sh.RunV("go", "build", "-o", "hexai", "./cmd/hexai") + return sh.RunV("go", "build", "-o", binaryName, "./cmd/hexai") } // BuildHexaiTmuxAction builds the hexai-tmux-action TUI binary. @@ -76,7 +89,7 @@ func Dev() error { if err := sh.RunV("go", "build", "-race", "-o", "hexai-lsp-server", "./cmd/hexai-lsp-server"); err != nil { return err } - if err := sh.RunV("go", "build", "-race", "-o", "hexai", "./cmd/hexai"); err != nil { + if err := sh.RunV("go", "build", "-race", "-o", binaryName, "./cmd/hexai"); err != nil { return err } if err := sh.RunV("go", "build", "-race", "-o", "hexai-tmux-action", "./cmd/hexai-tmux-action"); err != nil { @@ -122,7 +135,7 @@ func Install() error { for _, name := range []string{ "ask", "hexai-lsp-server", - "hexai", + binaryName, "hexai-tmux-action", "hexai-tmux-edit", "hexai-mcp-server", |
