diff --git a/go.mod b/go.mod index 3fcd4a9..aae31b8 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module git.milar.in/milarin/loadenv go 1.18 + +require git.milar.in/milarin/buildinfo v1.0.0 diff --git a/go.sum b/go.sum index e69de29..780b53f 100644 --- a/go.sum +++ b/go.sum @@ -0,0 +1,2 @@ +git.milar.in/milarin/buildinfo v1.0.0 h1:tw98GupUYl/0a/3aPGuezhE4wseycOSsbcLp70hy60U= +git.milar.in/milarin/buildinfo v1.0.0/go.mod h1:arI9ZoENOgcZcanv25k9y4dKDUhPp0buJrlVerGruas= diff --git a/main.go b/main.go index 5407cfa..3c135aa 100644 --- a/main.go +++ b/main.go @@ -8,6 +8,8 @@ import ( "os" "os/exec" "regexp" + + "git.milar.in/milarin/buildinfo" ) var ( @@ -15,11 +17,18 @@ var ( EnvVarRegex = regexp.MustCompile(`^(.*?)=(.*?)$`) EnvCommentRegex = regexp.MustCompile(`^[ \t]*#.*?$`) + + ShowVersion = flag.Bool("v", false, "show version and exit") ) func main() { flag.Parse() + if *ShowVersion { + buildinfo.Print(buildinfo.Options{}) + return + } + envFile, err := os.Open(*EnvFilePath) if err != nil { fmt.Fprintf(os.Stderr, "could not open file '%s': %s\n", *EnvFilePath, err.(*os.PathError).Err)