mirror of
https://github.com/onyx-and-iris/exclude.git
synced 2026-03-30 15:09:10 +00:00
add tests for all commands wrap entry point with fang add --version flag target to Taskfile
32 lines
563 B
Go
32 lines
563 B
Go
package main
|
|
|
|
import (
|
|
"context"
|
|
"os"
|
|
"runtime/debug"
|
|
"strings"
|
|
|
|
"github.com/charmbracelet/fang"
|
|
"github.com/onyx-and-iris/exclude/cmd"
|
|
)
|
|
|
|
var version string // Version of the CLI, set during build time
|
|
|
|
func main() {
|
|
if err := fang.Execute(context.Background(), cmd.RootCmd, fang.WithVersion(versionFromBuild())); err != nil {
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func versionFromBuild() string {
|
|
if version != "" {
|
|
return version
|
|
}
|
|
|
|
info, ok := debug.ReadBuildInfo()
|
|
if !ok {
|
|
return "(unable to read version)"
|
|
}
|
|
return strings.Split(info.Main.Version, "-")[0]
|
|
}
|