@@ -12,7 +12,7 @@ import product from "vs/platform/product/node/product";
1212import { ipcMain } from "vs/server/src/ipc" ;
1313import { enableCustomMarketplace } from "vs/server/src/marketplace" ;
1414import { 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" ;
1616
1717const { logger } = localRequire < typeof import ( "@coder/logger/out/index" ) > ( "@coder/logger/out/index" ) ;
1818setUnexpectedErrorHandler ( ( error ) => logger . warn ( error . message ) ) ;
@@ -22,6 +22,7 @@ interface Args extends ParsedArgs {
2222 "base-path" ?: string ;
2323 cert ?: string ;
2424 "cert-key" ?: string ;
25+ format ?: string ;
2526 host ?: string ;
2627 open ?: string ;
2728 port ?: string ;
@@ -66,6 +67,7 @@ const getArgs = (): Args => {
6667 options . push ( { id : "cert-key" , type : "string" , cat : "o" , description : "Path to the certificate's key if one was provided." } ) ;
6768 options . push ( { id : "extra-builtin-extensions-dir" , type : "string" , cat : "o" , description : "Path to an extra builtin extension directory." } ) ;
6869 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 ) } .` } ) ;
6971 options . push ( { id : "host" , type : "string" , cat : "o" , description : "Host for the server." } ) ;
7072 options . push ( { id : "auth" , type : "string" , cat : "o" , description : `The type of authentication to use. ${ buildAllowedMessage ( AuthType ) } .` } ) ;
7173 options . push ( { id : "open" , type : "boolean" , cat : "o" , description : "Open in the browser on startup." } ) ;
@@ -164,7 +166,15 @@ const startCli = (): boolean | Promise<void> => {
164166 }
165167
166168 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+ }
168178 return true ;
169179 }
170180
0 commit comments