@@ -29,27 +29,7 @@ export enum LogLevel {
29
29
30
30
export class OptionalString extends Optional < string > { }
31
31
32
- export interface Args
33
- extends Pick <
34
- CodeServerLib . NativeParsedArgs ,
35
- | "_"
36
- | "user-data-dir"
37
- | "enable-proposed-api"
38
- | "extensions-dir"
39
- | "builtin-extensions-dir"
40
- | "extra-extensions-dir"
41
- | "extra-builtin-extensions-dir"
42
- | "ignore-last-opened"
43
- | "locale"
44
- | "log"
45
- | "verbose"
46
- | "install-source"
47
- | "list-extensions"
48
- | "install-extension"
49
- | "uninstall-extension"
50
- | "locate-extension"
51
- // | "telemetry"
52
- > {
32
+ export interface Args extends CodeServerLib . ServerParsedArgs {
53
33
config ?: string
54
34
auth ?: AuthType
55
35
password ?: string
@@ -65,7 +45,6 @@ export interface Args
65
45
json ?: boolean
66
46
log ?: LogLevel
67
47
open ?: boolean
68
- port ?: number
69
48
"bind-addr" ?: string
70
49
socket ?: string
71
50
version ?: boolean
@@ -74,6 +53,7 @@ export interface Args
74
53
"proxy-domain" ?: string [ ]
75
54
"reuse-window" ?: boolean
76
55
"new-window" ?: boolean
56
+ verbose ?: boolean
77
57
78
58
link ?: OptionalString
79
59
}
@@ -167,7 +147,7 @@ const options: Options<Required<Args>> = {
167
147
168
148
// These two have been deprecated by bindAddr.
169
149
host : { type : "string" , description : "" } ,
170
- port : { type : "number " , description : "" } ,
150
+ port : { type : "string " , description : "" } ,
171
151
172
152
socket : { type : "string" , path : true , description : "Path to a socket (bind-addr will be ignored)." } ,
173
153
version : { type : "boolean" , short : "v" , description : "Display version information." } ,
@@ -176,31 +156,18 @@ const options: Options<Required<Args>> = {
176
156
"user-data-dir" : { type : "string" , path : true , description : "Path to the user data directory." } ,
177
157
"extensions-dir" : { type : "string" , path : true , description : "Path to the extensions directory." } ,
178
158
"builtin-extensions-dir" : { type : "string" , path : true } ,
179
- "extra-extensions-dir" : { type : "string[]" , path : true } ,
180
- "extra-builtin-extensions-dir" : { type : "string[]" , path : true } ,
181
159
"list-extensions" : { type : "boolean" , description : "List installed VS Code extensions." } ,
182
160
force : { type : "boolean" , description : "Avoid prompts when installing VS Code extensions." } ,
183
- "install-source" : { type : "string" } ,
184
161
"locate-extension" : { type : "string[]" } ,
185
162
"install-extension" : {
186
163
type : "string[]" ,
187
164
description :
188
165
"Install or update a VS Code extension by id or vsix. The identifier of an extension is `${publisher}.${name}`.\n" +
189
166
"To install a specific version provide `@${version}`. For example: 'vscode.csharp@1.2.3'." ,
190
167
} ,
191
- "enable-proposed-api" : {
192
- type : "string[]" ,
193
- description :
194
- "Enable proposed API features for extensions. Can receive one or more extension IDs to enable individually." ,
195
- } ,
196
168
"uninstall-extension" : { type : "string[]" , description : "Uninstall a VS Code extension by id." } ,
197
169
"show-versions" : { type : "boolean" , description : "Show VS Code extension versions." } ,
198
170
"proxy-domain" : { type : "string[]" , description : "Domain used for proxying ports." } ,
199
- "ignore-last-opened" : {
200
- type : "boolean" ,
201
- short : "e" ,
202
- description : "Ignore the last opened directory or workspace in favor of an empty window." ,
203
- } ,
204
171
"new-window" : {
205
172
type : "boolean" ,
206
173
short : "n" ,
@@ -212,7 +179,6 @@ const options: Options<Required<Args>> = {
212
179
description : "Force to open a file or folder in an already opened window." ,
213
180
} ,
214
181
215
- locale : { type : "string" } ,
216
182
log : { type : LogLevel } ,
217
183
verbose : { type : "boolean" , short : "vvv" , description : "Enable verbose logging." } ,
218
184
@@ -225,6 +191,43 @@ const options: Options<Required<Args>> = {
225
191
` ,
226
192
beta : true ,
227
193
} ,
194
+
195
+ connectionToken : { type : "string" } ,
196
+ "connection-secret" : {
197
+ type : "string" ,
198
+ description :
199
+ "Path to file that contains the connection token. This will require that all incoming connections know the secret." ,
200
+ } ,
201
+ "socket-path" : { type : "string" } ,
202
+ driver : { type : "string" } ,
203
+ "start-server" : { type : "boolean" } ,
204
+ "print-startup-performance" : { type : "boolean" } ,
205
+ "print-ip-address" : { type : "boolean" } ,
206
+ "disable-websocket-compression" : { type : "boolean" } ,
207
+
208
+ fileWatcherPolling : { type : "string" } ,
209
+
210
+ "enable-remote-auto-shutdown" : { type : "boolean" } ,
211
+ "remote-auto-shutdown-without-delay" : { type : "boolean" } ,
212
+
213
+ "without-browser-env-var" : { type : "boolean" } ,
214
+ "extensions-download-dir" : { type : "string" } ,
215
+ "install-builtin-extension" : { type : "string[]" } ,
216
+
217
+ category : {
218
+ type : "string" ,
219
+ description : "Filters installed extensions by provided category, when using --list-extensions." ,
220
+ } ,
221
+ "do-not-sync" : { type : "boolean" } ,
222
+ "force-disable-user-env" : { type : "boolean" } ,
223
+
224
+ folder : { type : "string" } ,
225
+ workspace : { type : "string" } ,
226
+ "web-user-data-dir" : { type : "string" } ,
227
+ "use-host-proxy" : { type : "string" } ,
228
+ "enable-sync" : { type : "boolean" } ,
229
+ "github-auth" : { type : "string" } ,
230
+ logsPath : { type : "string" } ,
228
231
}
229
232
230
233
export const optionDescriptions = ( ) : string [ ] => {
@@ -269,6 +272,14 @@ export function splitOnFirstEquals(str: string): string[] {
269
272
return split
270
273
}
271
274
275
+ const createDefaultArgs = ( ) : Args => {
276
+ return {
277
+ _ : [ ] ,
278
+ workspace : "" ,
279
+ folder : "" ,
280
+ }
281
+ }
282
+
272
283
export const parse = (
273
284
argv : string [ ] ,
274
285
opts ?: {
@@ -283,7 +294,8 @@ export const parse = (
283
294
return new Error ( msg )
284
295
}
285
296
286
- const args : Args = { _ : [ ] }
297
+ // TODO: parse workspace and folder.
298
+ const args : Args = createDefaultArgs ( )
287
299
let ended = false
288
300
289
301
for ( let i = 0 ; i < argv . length ; ++ i ) {
@@ -401,7 +413,7 @@ export interface DefaultedArgs extends ConfigArgs {
401
413
value : string
402
414
}
403
415
host : string
404
- port : number
416
+ port : string
405
417
"proxy-domain" : string [ ]
406
418
verbose : boolean
407
419
usingEnvPassword : boolean
@@ -470,15 +482,15 @@ export async function setDefaults(cliArgs: Args, configArgs?: ConfigArgs): Promi
470
482
args . auth = AuthType . Password
471
483
}
472
484
473
- const addr = bindAddrFromAllSources ( configArgs || { _ : [ ] } , cliArgs )
485
+ const addr = bindAddrFromAllSources ( configArgs || createDefaultArgs ( ) , cliArgs )
474
486
args . host = addr . host
475
- args . port = addr . port
487
+ args . port = addr . port . toString ( )
476
488
477
489
// If we're being exposed to the cloud, we listen on a random address and
478
490
// disable auth.
479
491
if ( args . link ) {
480
492
args . host = "localhost"
481
- args . port = 0
493
+ args . port = "0"
482
494
args . socket = undefined
483
495
args . cert = undefined
484
496
args . auth = AuthType . None
@@ -579,7 +591,7 @@ export async function readConfigFile(configPath?: string): Promise<ConfigArgs> {
579
591
*/
580
592
export function parseConfigFile ( configFile : string , configPath : string ) : ConfigArgs {
581
593
if ( ! configFile ) {
582
- return { _ : [ ] , config : configPath }
594
+ return { ... createDefaultArgs ( ) , config : configPath }
583
595
}
584
596
585
597
const config = yaml . load ( configFile , {
@@ -639,7 +651,7 @@ export function bindAddrFromArgs(addr: Addr, args: Args): Addr {
639
651
addr . port = parseInt ( process . env . PORT , 10 )
640
652
}
641
653
if ( args . port !== undefined ) {
642
- addr . port = args . port
654
+ addr . port = parseInt ( args . port , 10 )
643
655
}
644
656
return addr
645
657
}
0 commit comments