From 965034923b2b04d2b9e438fb89421bef0565cd18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lilian=20J=C3=B3nsd=C3=B3ttir?= Date: Sun, 11 Feb 2024 19:11:06 -0800 Subject: [PATCH] mage -> just just is more widely used thus has better tab completion, etc. also it's easier to write a justfile than a magefile --- justfile | 26 ++++++++++++++++++++++++++ magefile.go | 38 -------------------------------------- 2 files changed, 26 insertions(+), 38 deletions(-) create mode 100644 justfile delete mode 100644 magefile.go diff --git a/justfile b/justfile new file mode 100644 index 0000000..bb99183 --- /dev/null +++ b/justfile @@ -0,0 +1,26 @@ +binary := "fml" +build_dir := "bin" +cmd := "./cmd/" + binary +output := "." / build_dir / binary + +default: run + +# build binary +build: + go build -o {{output}} {{cmd}} + +# run from source +run: + go run {{cmd}} + +# build 'n run +run-binary: build + exec {{output}} + +# run with args +run-args args: + go run {{cmd}} {{args}} + +# clean up after yourself +clean: + rm {{output}} diff --git a/magefile.go b/magefile.go deleted file mode 100644 index 5fea045..0000000 --- a/magefile.go +++ /dev/null @@ -1,38 +0,0 @@ -//go:build mage - -package main - -import ( - "fmt" - "os" - - "github.com/magefile/mage/sh" -) - -var ( - binaryName string = "fml" - buildDir string = "bin" - cmd string = fmt.Sprintf(".%[1]ccmd%[1]c%[2]s", os.PathSeparator, binaryName) - output string = fmt.Sprintf(".%[1]c%[2]s%[1]c%[3]s", os.PathSeparator, buildDir, binaryName) -) - -func Build() error { - fmt.Println("Building...") - return sh.Run("go", "build", "-o", output, cmd) -} - -func Run() error { - fmt.Println("Running...") - return sh.RunV("go", "run", cmd) -} - -func RunBinary() error { - Build() - fmt.Println("Running binary...") - return sh.RunV(output) -} - -func Clean() error { - fmt.Println("Cleaning...") - return os.Remove(output) -}