2022-10-20 19:59:46 +00:00
|
|
|
package main
|
2021-04-20 21:31:37 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
)
|
|
|
|
|
|
|
|
var subCmdVersion = subCmd{
|
2024-12-10 21:07:25 +00:00
|
|
|
name: "version",
|
|
|
|
descr: "Dumps version and build info to stdout",
|
2024-09-04 20:35:29 +00:00
|
|
|
do: func(ctx subCmdCtx) error {
|
2024-12-10 21:07:25 +00:00
|
|
|
ctx, err := ctx.withParsedFlags(&withParsedFlagsOpts{
|
|
|
|
noNetwork: true,
|
|
|
|
})
|
|
|
|
if err != nil {
|
|
|
|
return fmt.Errorf("parsing flags: %w", err)
|
|
|
|
}
|
2021-04-20 21:31:37 +00:00
|
|
|
|
2022-10-26 22:37:03 +00:00
|
|
|
versionPath := filepath.Join(envAppDirPath, "share/version")
|
2021-04-20 21:31:37 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
},
|
|
|
|
}
|