isle/go/cmd/entrypoint/version.go

30 lines
561 B
Go
Raw Normal View History

package main
import (
"fmt"
"os"
"path/filepath"
)
var subCmdVersion = subCmd{
name: "version",
descr: "Dumps version and build info to stdout",
noNetwork: true,
2024-09-04 20:35:29 +00:00
do: func(ctx subCmdCtx) error {
2022-10-26 22:37:03 +00:00
versionPath := filepath.Join(envAppDirPath, "share/version")
version, err := os.ReadFile(versionPath)
if err != nil {
return fmt.Errorf("reading version info from %q: %w", versionPath, err)
}
if _, err := os.Stdout.Write(version); err != nil {
return fmt.Errorf("writing version info to stdout: %w", err)
}
return nil
},
}