@@ -12,7 +12,7 @@ import product from "vs/platform/product/node/product";
12
12
import { ipcMain } from "vs/server/src/ipc" ;
13
13
import { enableCustomMarketplace } from "vs/server/src/marketplace" ;
14
14
import { MainServer } from "vs/server/src/server" ;
15
- import { AuthType , buildAllowedMessage , enumToArray , generateCertificate , generatePassword , localRequire , open , unpackExecutables } from "vs/server/src/util" ;
15
+ import { AuthType , buildAllowedMessage , enumToArray , FormatType , generateCertificate , generatePassword , localRequire , open , unpackExecutables } from "vs/server/src/util" ;
16
16
17
17
const { logger } = localRequire < typeof import ( "@coder/logger/out/index" ) > ( "@coder/logger/out/index" ) ;
18
18
setUnexpectedErrorHandler ( ( error ) => logger . warn ( error . message ) ) ;
@@ -22,6 +22,7 @@ interface Args extends ParsedArgs {
22
22
"base-path" ?: string ;
23
23
cert ?: string ;
24
24
"cert-key" ?: string ;
25
+ format ?: string ;
25
26
host ?: string ;
26
27
open ?: string ;
27
28
port ?: string ;
@@ -66,6 +67,7 @@ const getArgs = (): Args => {
66
67
options . push ( { id : "cert-key" , type : "string" , cat : "o" , description : "Path to the certificate's key if one was provided." } ) ;
67
68
options . push ( { id : "extra-builtin-extensions-dir" , type : "string" , cat : "o" , description : "Path to an extra builtin extension directory." } ) ;
68
69
options . push ( { id : "extra-extensions-dir" , type : "string" , cat : "o" , description : "Path to an extra user extension directory." } ) ;
70
+ options . push ( { id : "format" , type : "string" , cat : "o" , description : `Format for the version. ${ buildAllowedMessage ( FormatType ) } .` } ) ;
69
71
options . push ( { id : "host" , type : "string" , cat : "o" , description : "Host for the server." } ) ;
70
72
options . push ( { id : "auth" , type : "string" , cat : "o" , description : `The type of authentication to use. ${ buildAllowedMessage ( AuthType ) } .` } ) ;
71
73
options . push ( { id : "open" , type : "boolean" , cat : "o" , description : "Open in the browser on startup." } ) ;
@@ -164,7 +166,15 @@ const startCli = (): boolean | Promise<void> => {
164
166
}
165
167
166
168
if ( args . version ) {
167
- buildVersionMessage ( pkg . codeServerVersion , product . commit ) . split ( "\n" ) . map ( ( line ) => logger . info ( line ) ) ;
169
+ if ( args . format === "json" ) {
170
+ console . log ( JSON . stringify ( {
171
+ codeServerVersion : pkg . codeServerVersion ,
172
+ commit : product . commit ,
173
+ vscodeVersion : pkg . version ,
174
+ } ) ) ;
175
+ } else {
176
+ buildVersionMessage ( pkg . codeServerVersion , product . commit ) . split ( "\n" ) . map ( ( line ) => logger . info ( line ) ) ;
177
+ }
168
178
return true ;
169
179
}
170
180
0 commit comments