@@ -31,27 +31,7 @@ export enum LogLevel {
31
31
32
32
export class OptionalString extends Optional < string > { }
33
33
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 {
55
35
config ?: string
56
36
auth ?: AuthType
57
37
password ?: string
@@ -67,7 +47,6 @@ export interface Args
67
47
json ?: boolean
68
48
log ?: LogLevel
69
49
open ?: boolean
70
- port ?: number
71
50
"bind-addr" ?: string
72
51
socket ?: string
73
52
version ?: boolean
@@ -76,6 +55,7 @@ export interface Args
76
55
"proxy-domain" ?: string [ ]
77
56
"reuse-window" ?: boolean
78
57
"new-window" ?: boolean
58
+ verbose ?: boolean
79
59
80
60
link ?: OptionalString
81
61
}
@@ -169,7 +149,7 @@ const options: Options<Required<Args>> = {
169
149
170
150
// These two have been deprecated by bindAddr.
171
151
host : { type : "string" , description : "" } ,
172
- port : { type : "number " , description : "" } ,
152
+ port : { type : "string " , description : "" } ,
173
153
174
154
socket : { type : "string" , path : true , description : "Path to a socket (bind-addr will be ignored)." } ,
175
155
version : { type : "boolean" , short : "v" , description : "Display version information." } ,
@@ -178,31 +158,18 @@ const options: Options<Required<Args>> = {
178
158
"user-data-dir" : { type : "string" , path : true , description : "Path to the user data directory." } ,
179
159
"extensions-dir" : { type : "string" , path : true , description : "Path to the extensions directory." } ,
180
160
"builtin-extensions-dir" : { type : "string" , path : true } ,
181
- "extra-extensions-dir" : { type : "string[]" , path : true } ,
182
- "extra-builtin-extensions-dir" : { type : "string[]" , path : true } ,
183
161
"list-extensions" : { type : "boolean" , description : "List installed VS Code extensions." } ,
184
162
force : { type : "boolean" , description : "Avoid prompts when installing VS Code extensions." } ,
185
- "install-source" : { type : "string" } ,
186
163
"locate-extension" : { type : "string[]" } ,
187
164
"install-extension" : {
188
165
type : "string[]" ,
189
166
description :
190
167
"Install or update a VS Code extension by id or vsix. The identifier of an extension is `${publisher}.${name}`.\n" +
191
168
"To install a specific version provide `@${version}`. For example: '[email protected] '." ,
192
169
} ,
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
- } ,
198
170
"uninstall-extension" : { type : "string[]" , description : "Uninstall a VS Code extension by id." } ,
199
171
"show-versions" : { type : "boolean" , description : "Show VS Code extension versions." } ,
200
172
"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
- } ,
206
173
"new-window" : {
207
174
type : "boolean" ,
208
175
short : "n" ,
@@ -214,7 +181,6 @@ const options: Options<Required<Args>> = {
214
181
description : "Force to open a file or folder in an already opened window." ,
215
182
} ,
216
183
217
- locale : { type : "string" } ,
218
184
log : { type : LogLevel } ,
219
185
verbose : { type : "boolean" , short : "vvv" , description : "Enable verbose logging." } ,
220
186
@@ -227,6 +193,43 @@ const options: Options<Required<Args>> = {
227
193
` ,
228
194
beta : true ,
229
195
} ,
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" } ,
230
233
}
231
234
232
235
export const optionDescriptions = ( ) : string [ ] => {
@@ -271,6 +274,14 @@ export function splitOnFirstEquals(str: string): string[] {
271
274
return split
272
275
}
273
276
277
+ const createDefaultArgs = ( ) : Args => {
278
+ return {
279
+ _ : [ ] ,
280
+ workspace : "" ,
281
+ folder : "" ,
282
+ }
283
+ }
284
+
274
285
export const parse = (
275
286
argv : string [ ] ,
276
287
opts ?: {
@@ -285,7 +296,8 @@ export const parse = (
285
296
return new Error ( msg )
286
297
}
287
298
288
- const args : Args = { _ : [ ] }
299
+ // TODO: parse workspace and folder.
300
+ const args : Args = createDefaultArgs ( )
289
301
let ended = false
290
302
291
303
for ( let i = 0 ; i < argv . length ; ++ i ) {
@@ -403,7 +415,7 @@ export interface DefaultedArgs extends ConfigArgs {
403
415
value : string
404
416
}
405
417
host : string
406
- port : number
418
+ port : string
407
419
"proxy-domain" : string [ ]
408
420
verbose : boolean
409
421
usingEnvPassword : boolean
@@ -472,15 +484,15 @@ export async function setDefaults(cliArgs: Args, configArgs?: ConfigArgs): Promi
472
484
args . auth = AuthType . Password
473
485
}
474
486
475
- const addr = bindAddrFromAllSources ( configArgs || { _ : [ ] } , cliArgs )
487
+ const addr = bindAddrFromAllSources ( configArgs || createDefaultArgs ( ) , cliArgs )
476
488
args . host = addr . host
477
- args . port = addr . port
489
+ args . port = addr . port . toString ( )
478
490
479
491
// If we're being exposed to the cloud, we listen on a random address and
480
492
// disable auth.
481
493
if ( args . link ) {
482
494
args . host = "localhost"
483
- args . port = 0
495
+ args . port = "0"
484
496
args . socket = undefined
485
497
args . cert = undefined
486
498
args . auth = AuthType . None
@@ -581,7 +593,7 @@ export async function readConfigFile(configPath?: string): Promise<ConfigArgs> {
581
593
*/
582
594
export function parseConfigFile ( configFile : string , configPath : string ) : ConfigArgs {
583
595
if ( ! configFile ) {
584
- return { _ : [ ] , config : configPath }
596
+ return { ... createDefaultArgs ( ) , config : configPath }
585
597
}
586
598
587
599
const config = yaml . load ( configFile , {
@@ -641,7 +653,7 @@ export function bindAddrFromArgs(addr: Addr, args: Args): Addr {
641
653
addr . port = parseInt ( process . env . PORT , 10 )
642
654
}
643
655
if ( args . port !== undefined ) {
644
- addr . port = args . port
656
+ addr . port = parseInt ( args . port , 10 )
645
657
}
646
658
return addr
647
659
}
0 commit comments