mirror of
https://github.com/onyx-and-iris/exclude.git
synced 2026-04-16 14:13:39 +00:00
add del command
add tests for all commands wrap entry point with fang add --version flag target to Taskfile
This commit is contained in:
28
main.go
28
main.go
@@ -1,7 +1,31 @@
|
||||
package main
|
||||
|
||||
import "github.com/onyx-and-iris/exclude/cmd"
|
||||
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() {
|
||||
cmd.Execute()
|
||||
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]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user