From 1f3ae20a9830fd776f6ef3c11b4c198154b8205f Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Thu, 11 Jun 2026 00:18:01 +0300 Subject: 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 --- Magefile.go | 21 +++++++++++++++++---- 1 file 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", -- cgit v1.2.3