show version
This commit is contained in:
parent
f4ed6a3921
commit
b3eb63251f
2
go.mod
2
go.mod
@ -1,3 +1,5 @@
|
|||||||
module git.milar.in/milarin/loadenv
|
module git.milar.in/milarin/loadenv
|
||||||
|
|
||||||
go 1.18
|
go 1.18
|
||||||
|
|
||||||
|
require git.milar.in/milarin/buildinfo v1.0.0
|
||||||
|
2
go.sum
2
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=
|
9
main.go
9
main.go
@ -8,6 +8,8 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"regexp"
|
"regexp"
|
||||||
|
|
||||||
|
"git.milar.in/milarin/buildinfo"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
@ -15,11 +17,18 @@ var (
|
|||||||
|
|
||||||
EnvVarRegex = regexp.MustCompile(`^(.*?)=(.*?)$`)
|
EnvVarRegex = regexp.MustCompile(`^(.*?)=(.*?)$`)
|
||||||
EnvCommentRegex = regexp.MustCompile(`^[ \t]*#.*?$`)
|
EnvCommentRegex = regexp.MustCompile(`^[ \t]*#.*?$`)
|
||||||
|
|
||||||
|
ShowVersion = flag.Bool("v", false, "show version and exit")
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
|
if *ShowVersion {
|
||||||
|
buildinfo.Print(buildinfo.Options{})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
envFile, err := os.Open(*EnvFilePath)
|
envFile, err := os.Open(*EnvFilePath)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "could not open file '%s': %s\n", *EnvFilePath, err.(*os.PathError).Err)
|
fmt.Fprintf(os.Stderr, "could not open file '%s': %s\n", *EnvFilePath, err.(*os.PathError).Err)
|
||||||
|
Loading…
Reference in New Issue
Block a user