29 lines
558 B
Go
29 lines
558 B
Go
|
package entrypoint
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"os"
|
||
|
"path/filepath"
|
||
|
)
|
||
|
|
||
|
var subCmdVersion = subCmd{
|
||
|
name: "version",
|
||
|
descr: "Dumps version and build info to stdout",
|
||
|
do: func(subCmdCtx subCmdCtx) error {
|
||
|
|
||
|
versionPath := filepath.Join(subCmdCtx.env.AppDirPath, "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
|
||
|
},
|
||
|
}
|