mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
feat(cli): add --output={text,json} to version cmd (#7010)
* feat(cliui): add TextFormat
* feat(cli): add --format={text,json} to version cmd
This commit is contained in:
+1
-31
@@ -82,7 +82,7 @@ func (r *RootCmd) Core() []*clibase.Cmd {
|
||||
r.templates(),
|
||||
r.users(),
|
||||
r.tokens(),
|
||||
r.version(),
|
||||
r.version(defaultVersionInfo),
|
||||
|
||||
// Workspace Commands
|
||||
r.configSSH(),
|
||||
@@ -370,36 +370,6 @@ func LoggerFromContext(ctx context.Context) (slog.Logger, bool) {
|
||||
return l, ok
|
||||
}
|
||||
|
||||
// version prints the coder version
|
||||
func (*RootCmd) version() *clibase.Cmd {
|
||||
return &clibase.Cmd{
|
||||
Use: "version",
|
||||
Short: "Show coder version",
|
||||
Handler: func(inv *clibase.Invocation) error {
|
||||
var str strings.Builder
|
||||
_, _ = str.WriteString("Coder ")
|
||||
if buildinfo.IsAGPL() {
|
||||
_, _ = str.WriteString("(AGPL) ")
|
||||
}
|
||||
_, _ = str.WriteString(buildinfo.Version())
|
||||
buildTime, valid := buildinfo.Time()
|
||||
if valid {
|
||||
_, _ = str.WriteString(" " + buildTime.Format(time.UnixDate))
|
||||
}
|
||||
_, _ = str.WriteString("\r\n" + buildinfo.ExternalURL() + "\r\n\r\n")
|
||||
|
||||
if buildinfo.IsSlim() {
|
||||
_, _ = str.WriteString(fmt.Sprintf("Slim build of Coder, does not support the %s subcommand.\n", cliui.Styles.Code.Render("server")))
|
||||
} else {
|
||||
_, _ = str.WriteString(fmt.Sprintf("Full build of Coder, supports the %s subcommand.\n", cliui.Styles.Code.Render("server")))
|
||||
}
|
||||
|
||||
_, _ = fmt.Fprint(inv.Stdout, str.String())
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
func isTest() bool {
|
||||
return flag.Lookup("test.v") != nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user