@@ -31,27 +31,7 @@ export enum LogLevel {
3131
3232export class OptionalString extends Optional < string > { }
3333
34- export interface Args
35- extends Pick <
36- CodeServerLib . NativeParsedArgs ,
37- | "_"
38- | "user-data-dir"
39- | "enable-proposed-api"
40- | "extensions-dir"
41- | "builtin-extensions-dir"
42- | "extra-extensions-dir"
43- | "extra-builtin-extensions-dir"
44- | "ignore-last-opened"
45- | "locale"
46- | "log"
47- | "verbose"
48- | "install-source"
49- | "list-extensions"
50- | "install-extension"
51- | "uninstall-extension"
52- | "locate-extension"
53- // | "telemetry"
54- > {
34+ export interface Args extends CodeServerLib . ServerParsedArgs {
5535 config ?: string
5636 auth ?: AuthType
5737 password ?: string
@@ -67,7 +47,6 @@ export interface Args
6747 json ?: boolean
6848 log ?: LogLevel
6949 open ?: boolean
70- port ?: number
7150 "bind-addr" ?: string
7251 socket ?: string
7352 version ?: boolean
@@ -76,6 +55,7 @@ export interface Args
7655 "proxy-domain" ?: string [ ]
7756 "reuse-window" ?: boolean
7857 "new-window" ?: boolean
58+ verbose ?: boolean
7959
8060 link ?: OptionalString
8161}
@@ -169,7 +149,7 @@ const options: Options<Required<Args>> = {
169149
170150 // These two have been deprecated by bindAddr.
171151 host : { type : "string" , description : "" } ,
172- port : { type : "number " , description : "" } ,
152+ port : { type : "string " , description : "" } ,
173153
174154 socket : { type : "string" , path : true , description : "Path to a socket (bind-addr will be ignored)." } ,
175155 version : { type : "boolean" , short : "v" , description : "Display version information." } ,
@@ -178,31 +158,18 @@ const options: Options<Required<Args>> = {
178158 "user-data-dir" : { type : "string" , path : true , description : "Path to the user data directory." } ,
179159 "extensions-dir" : { type : "string" , path : true , description : "Path to the extensions directory." } ,
180160 "builtin-extensions-dir" : { type : "string" , path : true } ,
181- "extra-extensions-dir" : { type : "string[]" , path : true } ,
182- "extra-builtin-extensions-dir" : { type : "string[]" , path : true } ,
183161 "list-extensions" : { type : "boolean" , description : "List installed VS Code extensions." } ,
184162 force : { type : "boolean" , description : "Avoid prompts when installing VS Code extensions." } ,
185- "install-source" : { type : "string" } ,
186163 "locate-extension" : { type : "string[]" } ,
187164 "install-extension" : {
188165 type : "string[]" ,
189166 description :
190167 "Install or update a VS Code extension by id or vsix. The identifier of an extension is `${publisher}.${name}`.\n" +
191168 "To install a specific version provide `@${version}`. For example: '[email protected] '." , 192169 } ,
193- "enable-proposed-api" : {
194- type : "string[]" ,
195- description :
196- "Enable proposed API features for extensions. Can receive one or more extension IDs to enable individually." ,
197- } ,
198170 "uninstall-extension" : { type : "string[]" , description : "Uninstall a VS Code extension by id." } ,
199171 "show-versions" : { type : "boolean" , description : "Show VS Code extension versions." } ,
200172 "proxy-domain" : { type : "string[]" , description : "Domain used for proxying ports." } ,
201- "ignore-last-opened" : {
202- type : "boolean" ,
203- short : "e" ,
204- description : "Ignore the last opened directory or workspace in favor of an empty window." ,
205- } ,
206173 "new-window" : {
207174 type : "boolean" ,
208175 short : "n" ,
@@ -214,7 +181,6 @@ const options: Options<Required<Args>> = {
214181 description : "Force to open a file or folder in an already opened window." ,
215182 } ,
216183
217- locale : { type : "string" } ,
218184 log : { type : LogLevel } ,
219185 verbose : { type : "boolean" , short : "vvv" , description : "Enable verbose logging." } ,
220186
@@ -227,6 +193,43 @@ const options: Options<Required<Args>> = {
227193 ` ,
228194 beta : true ,
229195 } ,
196+
197+ connectionToken : { type : "string" } ,
198+ "connection-secret" : {
199+ type : "string" ,
200+ description :
201+ "Path to file that contains the connection token. This will require that all incoming connections know the secret." ,
202+ } ,
203+ "socket-path" : { type : "string" } ,
204+ driver : { type : "string" } ,
205+ "start-server" : { type : "boolean" } ,
206+ "print-startup-performance" : { type : "boolean" } ,
207+ "print-ip-address" : { type : "boolean" } ,
208+ "disable-websocket-compression" : { type : "boolean" } ,
209+
210+ fileWatcherPolling : { type : "string" } ,
211+
212+ "enable-remote-auto-shutdown" : { type : "boolean" } ,
213+ "remote-auto-shutdown-without-delay" : { type : "boolean" } ,
214+
215+ "without-browser-env-var" : { type : "boolean" } ,
216+ "extensions-download-dir" : { type : "string" } ,
217+ "install-builtin-extension" : { type : "string[]" } ,
218+
219+ category : {
220+ type : "string" ,
221+ description : "Filters installed extensions by provided category, when using --list-extensions." ,
222+ } ,
223+ "do-not-sync" : { type : "boolean" } ,
224+ "force-disable-user-env" : { type : "boolean" } ,
225+
226+ folder : { type : "string" } ,
227+ workspace : { type : "string" } ,
228+ "web-user-data-dir" : { type : "string" } ,
229+ "use-host-proxy" : { type : "string" } ,
230+ "enable-sync" : { type : "boolean" } ,
231+ "github-auth" : { type : "string" } ,
232+ logsPath : { type : "string" } ,
230233}
231234
232235export const optionDescriptions = ( ) : string [ ] => {
@@ -271,6 +274,14 @@ export function splitOnFirstEquals(str: string): string[] {
271274 return split
272275}
273276
277+ const createDefaultArgs = ( ) : Args => {
278+ return {
279+ _ : [ ] ,
280+ workspace : "" ,
281+ folder : "" ,
282+ }
283+ }
284+
274285export const parse = (
275286 argv : string [ ] ,
276287 opts ?: {
@@ -285,7 +296,8 @@ export const parse = (
285296 return new Error ( msg )
286297 }
287298
288- const args : Args = { _ : [ ] }
299+ // TODO: parse workspace and folder.
300+ const args : Args = createDefaultArgs ( )
289301 let ended = false
290302
291303 for ( let i = 0 ; i < argv . length ; ++ i ) {
@@ -403,7 +415,7 @@ export interface DefaultedArgs extends ConfigArgs {
403415 value : string
404416 }
405417 host : string
406- port : number
418+ port : string
407419 "proxy-domain" : string [ ]
408420 verbose : boolean
409421 usingEnvPassword : boolean
@@ -472,15 +484,15 @@ export async function setDefaults(cliArgs: Args, configArgs?: ConfigArgs): Promi
472484 args . auth = AuthType . Password
473485 }
474486
475- const addr = bindAddrFromAllSources ( configArgs || { _ : [ ] } , cliArgs )
487+ const addr = bindAddrFromAllSources ( configArgs || createDefaultArgs ( ) , cliArgs )
476488 args . host = addr . host
477- args . port = addr . port
489+ args . port = addr . port . toString ( )
478490
479491 // If we're being exposed to the cloud, we listen on a random address and
480492 // disable auth.
481493 if ( args . link ) {
482494 args . host = "localhost"
483- args . port = 0
495+ args . port = "0"
484496 args . socket = undefined
485497 args . cert = undefined
486498 args . auth = AuthType . None
@@ -581,7 +593,7 @@ export async function readConfigFile(configPath?: string): Promise<ConfigArgs> {
581593 */
582594export function parseConfigFile ( configFile : string , configPath : string ) : ConfigArgs {
583595 if ( ! configFile ) {
584- return { _ : [ ] , config : configPath }
596+ return { ... createDefaultArgs ( ) , config : configPath }
585597 }
586598
587599 const config = yaml . load ( configFile , {
@@ -641,7 +653,7 @@ export function bindAddrFromArgs(addr: Addr, args: Args): Addr {
641653 addr . port = parseInt ( process . env . PORT , 10 )
642654 }
643655 if ( args . port !== undefined ) {
644- addr . port = args . port
656+ addr . port = parseInt ( args . port , 10 )
645657 }
646658 return addr
647659}
0 commit comments