ide на основе vs code · VibeGit
ide на основе vs code Это ide на основе vs code(code oss), в ней будет встроенный умный апи роутинг, свой маркет с плагинами(агент харнесс, поддержка java/kotlin/мобильной разработки, командная разработка проектов, orca, оркестратор агентов
krutaya-ide-na-osnove-vs-code / cli / src / commands / args.rs 1146 строк · изменён 14 нояб., 04:52
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
use std:: { fmt, path:: PathBuf } ;
use crate :: { constants, log, options, tunnels:: code_server:: CodeServerArgs } ;
use clap:: { Args , Parser , Subcommand , ValueEnum } ;
use const_format:: concatcp;
const CLI_NAME : & str = concatcp! ( constants::
c c
c c
core
open_paths
editor_options
troubleshooting
global_options
subcommand
core
subcommand
cli cli core
cli cli core
args open_paths
editor_options args
troubleshooting args
global_options args
args
cli
args
log cli global_options log
accept_server_license_terms
args log cli global_options log
args accept_server_license_terms
cli global_options verbose
args verbose
cli global_options disable_telemetry
args telemetry_level
cli global_options telemetry_level
args telemetry_level cli global_options telemetry_level
args
check
host
socket_path
port
connection_token
connection_token_file
without_connection_token
accept_server_license_terms
server_base_path
server_data_dir
default_folder
default_workspace
disable_telemetry
commit_id
host
port
connection_token
connection_token_file
without_connection_token
server_data_dir
user_data_dir
replace
new_instance
foreground
tunnel
name
random_name
idle_timeout
existing_tunnel
subcommand
host_args
user_data_dir
instance_id
user_data_dir
user_data_dir
address
tunnel
discovery
json
all
session
discovery
session
discovery
user_data_dir
instance_id
server_args
on_socket
on_port
# clap long
on_host
require_token
parent_process_id
subcommand
desktop_code_options
target
desktop_code_options target
subcommand target
target
args
target
args show_versions
target
category args category
target
args
id args id_or_path
target
args pre_release
target
args donot_include_pack_and_dependencies
target
args force
target
args
id args id
target
target
category
show_versions
id_or_path
pre_release
donot_include_pack_and_dependencies
force
id
subcommand
name
install_dir
# short long value_names
diff
add
goto
new_window
reuse_window
wait
locale
enable_proposed_api
code_options
target
diff
target
file diff
target file
add add
target
target add
goto goto
target
target goto
new_window
target
reuse_window
target
wait
target
locale locale
target
enable_proposed_api
id enable_proposed_api
target
code_options target
extensions_dir
user_data_dir
use_version
format
target
extensions_dir extensions_dir
target
user_data_dir user_data_dir
target
cli_data_dir
verbose
log_to_file
log
disable_telemetry
telemetry_level
target
verbose
target
log log
target
disable_telemetry
target
telemetry_level telemetry_level
target
prof_startup
disable_extensions
disable_extension
sync
inspect_extensions
inspect_brk_extensions
disable_gpu
telemetry
target
prof_startup
target
disable_extensions
target
id disable_extension
target
sync sync
target
port inspect_extensions
target
port inspect_brk_extensions
target
disable_gpu
target
telemetry
target
f
f
f
tunnel_name
host_token
tunnel_id
cluster
server_args
tunnel
random_name
no_sleep
name
parent_process_id
accept_server_license_terms
user_data_dir
agent_host_only
machine_status
delegate_to_editor
install_extension
server_data_dir
extensions_dir
reconnection_grace_time
csa
csa install_extensions
install_extension
d server_data_dir
csa server_data_dir d
d extensions_dir
csa extensions_dir d
t reconnection_grace_time
csa reconnection_grace_time t
subcommand
serve_args
accept_server_license_terms
name
name
ports
login
access_token
refresh_token
provider
args
cli args
tunnel_args cli core subcommand
tunnel_args serve_args machine_status
previous_value
previous_value
value value
PRODUCT_NAME_LONG
,
" CLI"
)
;
const
HELP_COMMANDS
:
&
str
=
concatcp!
(
"Usage: "
,
constants::
APPLICATION_NAME
,
" [options][paths...]
To read output from another program, append '-' (e.g. 'echo Hello World | {name} -')"
)
;
const
STANDALONE_TEMPLATE
:
&
str
=
concatcp!
(
CLI_NAME
,
" Standalone - {version}
"
,
HELP_COMMANDS
,
"
Running editor commands requires installing "
,
constants::
QUALITYLESS_PRODUCT_NAME
,
", and may differ slightly.
{all-args}"
)
;
const
INTEGRATED_TEMPLATE
:
&
str
=
concatcp!
(
CLI_NAME
,
" - {version}
"
,
HELP_COMMANDS
,
"
{all-args}"
)
;
const
COMMIT_IN_VERSION
:
&
str
=
match
constants::
VSCODE_CLI_COMMIT
{
Some
(
)
=>
,
None
=>
"unknown"
,
}
;
const
NUMBER_IN_VERSION
:
&
str
=
match
constants::
VSCODE_CLI_VERSION
{
Some
(
)
=>
,
None
=>
"dev"
,
}
;
const
VERSION
:
&
str
=
concatcp!
(
NUMBER_IN_VERSION
,
" (commit "
,
COMMIT_IN_VERSION
,
")"
)
;
#[derive(Parser, Debug, Default)]
#[clap(
help_template = INTEGRATED_TEMPLATE,
long_about = None,
name = constants::APPLICATION_NAME,
version = VERSION,
)]
pub
struct
IntegratedCli
{
#[clap(flatten)]
pub
:
CliCore
,
}
#[derive(Args, Debug, Default, Clone)]
pub
struct
CliCore
{
#[clap(name = "paths" )]
pub
:
Vec
<
String
>
,
#[clap(flatten, next_help_heading = Some("EDITOR OPTIONS" ))]
pub
:
EditorOptions
,
#[clap(flatten, next_help_heading = Some("EDITOR TROUBLESHOOTING" ))]
pub
:
EditorTroubleshooting
,
#[clap(flatten, next_help_heading = Some("GLOBAL OPTIONS" ))]
pub
:
GlobalOptions
,
#[clap(subcommand)]
pub
:
Option
<
Commands
>
,
}
#[derive(Parser, Debug, Default)]
#[clap(
help_template = STANDALONE_TEMPLATE,
long_about = None,
version = VERSION,
name = constants::APPLICATION_NAME,
)]
pub
struct
StandaloneCli
{
#[clap(flatten)]
pub
:
CliCore
,
#[clap(subcommand)]
pub
:
Option
<
StandaloneCommands
>
,
}
pub
enum
AnyCli
{
Integrated
(
IntegratedCli
)
,
Standalone
(
StandaloneCli
)
,
}
impl
AnyCli
{
pub
fn
core
(
&
self
)
->
&
CliCore
{
match
self
{
AnyCli
::
Integrated
(
)
=>
&
.
,
AnyCli
::
Standalone
(
)
=>
&
.
,
}
}
}
impl
CliCore
{
pub
fn
get_base_code_args
(
&
self
)
->
Vec
<
String
>
{
let
mut
=
self
.
.
clone
(
)
;
self
.
.
add_code_args
(
&
mut
)
;
self
.
.
add_code_args
(
&
mut
)
;
self
.
.
add_code_args
(
&
mut
)
;
}
}
impl
<
'a
>
From
<
&
'a
CliCore
>
for
CodeServerArgs
{
fn
from
(
:
&
'a
CliCore
)
->
Self
{
let
mut
=
CodeServerArgs
{
:
.
.
,
:
true
,
..
Default
::
default
(
)
}
;
.
=
.
.
;
.
=
true
;
if
.
.
{
.
=
true
;
}
if
.
.
{
.
=
Some
(
options::
TelemetryLevel
::
Off
)
;
}
else
if
.
.
.
is_some
(
)
{
.
=
.
.
;
}
}
}
#[derive(Subcommand, Debug, Clone)]
pub
enum
StandaloneCommands
{
Update
(
StandaloneUpdateArgs
)
,
}
#[derive(Args, Debug, Clone)]
pub
struct
StandaloneUpdateArgs
{
#[clap(long)]
pub
:
bool
,
}
#[derive(Subcommand, Debug, Clone)]
pub
enum
Commands
{
Tunnel
(
TunnelArgs
)
,
#[clap(name = "ext" )]
Extension
(
ExtensionArgs
)
,
Status
,
Version
(
VersionArgs
)
,
#[clap(about = concatcp!("Runs a local web version of " , constants::PRODUCT_NAME_LONG))]
ServeWeb
(
ServeWebArgs
)
,
#[clap(hide = true)]
CommandShell
(
CommandShellArgs
)
,
#[clap(name = "agent" )]
Agent
(
Box
<
AgentArgs
>
)
,
}
#[derive(Args, Debug, Clone)]
pub
struct
ServeWebArgs
{
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long, default_value_t = 8000)]
pub
:
u16
,
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
bool
,
#[clap(long)]
pub
:
bool
,
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
bool
,
#[clap(long)]
pub
:
Option
<
String
>
,
}
#[derive(Args, Debug, Clone, Default)]
pub
struct
AgentHostArgs
{
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long, default_value_t = 0)]
pub
:
u16
,
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
bool
,
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
bool
,
#[clap(long)]
pub
:
bool
,
#[clap(long)]
pub
:
bool
,
#[clap(long)]
pub
:
bool
,
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
bool
,
#[clap(long)]
pub
:
Option
<
u64
>
,
#[clap(flatten, next_help_heading = Some("ADVANCED TUNNEL OPTIONS" ))]
pub
:
ExistingTunnelArgs
,
}
#[derive(Args, Debug, Clone)]
pub
struct
AgentArgs
{
#[clap(subcommand)]
pub
:
Option
<
AgentSubcommand
>
,
#[clap(flatten)]
pub
:
AgentHostArgs
,
}
#[derive(Subcommand, Debug, Clone)]
pub
enum
AgentSubcommand
{
Host
(
AgentHostArgs
)
,
Ps
(
AgentPsArgs
)
,
Stop
(
AgentStopArgs
)
,
Kill
(
AgentKillArgs
)
,
Logs
(
AgentLogsArgs
)
,
Endpoints
(
AgentEndpointsArgs
)
,
#[clap(hide = true)]
Relay
(
AgentRelayArgs
)
,
}
#[derive(Args, Debug, Clone)]
pub
struct
AgentEndpointsArgs
{
#[clap(long)]
pub
:
Option
<
String
>
,
}
#[derive(Args, Debug, Clone)]
pub
struct
AgentRelayArgs
{
pub
:
String
,
#[clap(long)]
pub
:
Option
<
String
>
,
}
#[derive(Args, Debug, Clone)]
pub
struct
AgentDiscoveryArgs
{
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
Option
<
String
>
,
}
#[derive(Args, Debug, Clone)]
pub
struct
AgentPsArgs
{
#[clap(flatten)]
pub
:
AgentDiscoveryArgs
,
#[clap(long)]
pub
:
bool
,
#[clap(long, short)]
pub
:
bool
,
}
#[derive(Args, Debug, Clone)]
pub
struct
AgentStopArgs
{
pub
:
String
,
#[clap(flatten)]
pub
:
AgentDiscoveryArgs
,
}
#[derive(Args, Debug, Clone)]
pub
struct
AgentLogsArgs
{
pub
:
String
,
#[clap(flatten)]
pub
:
AgentDiscoveryArgs
,
}
#[derive(Args, Debug, Clone)]
pub
struct
AgentKillArgs
{
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
Option
<
String
>
,
}
#[derive(Args, Debug, Clone)]
pub
struct
CommandShellArgs
{
#[clap(flatten)]
pub
:
BaseServerArgs
,
#[clap(long)]
pub
:
bool
,
#[clap(long, num_args = 0..=2, default_missing_value = "0" )]
pub
:
Vec
<
u16
>
,
[
[
]
]
pub
:
Option
<
String
>
,
#[clap(long, env = "VSCODE_CLI_REQUIRE_TOKEN" )]
pub
:
Option
<
String
>
,
#[clap(long, hide = true)]
pub
:
Option
<
String
>
,
}
#[derive(Args, Debug, Clone)]
pub
struct
ExtensionArgs
{
#[clap(subcommand)]
pub
:
ExtensionSubcommand
,
#[clap(flatten)]
pub
:
DesktopCodeOptions
,
}
impl
ExtensionArgs
{
pub
fn
add_code_args
(
&
self
,
:
&
mut
Vec
<
String
>
)
{
self
.
.
add_code_args
(
)
;
self
.
.
add_code_args
(
)
;
}
}
#[derive(Subcommand, Debug, Clone)]
pub
enum
ExtensionSubcommand
{
List
(
ListExtensionArgs
)
,
Install
(
InstallExtensionArgs
)
,
Uninstall
(
UninstallExtensionArgs
)
,
Update
,
}
impl
ExtensionSubcommand
{
pub
fn
add_code_args
(
&
self
,
:
&
mut
Vec
<
String
>
)
{
match
self
{
ExtensionSubcommand
::
List
(
)
=>
{
.
push
(
"--list-extensions"
.
to_string
(
)
)
;
if
.
{
.
push
(
"--show-versions"
.
to_string
(
)
)
;
}
if
let
Some
(
)
=
&
.
{
.
push
(
format!
(
"--category={category}"
)
)
;
}
}
ExtensionSubcommand
::
Install
(
)
=>
{
for
in
.
.
iter
(
)
{
.
push
(
format!
(
"--install-extension={id}"
)
)
;
}
if
.
{
.
push
(
"--pre-release"
.
to_string
(
)
)
;
}
if
.
{
.
push
(
"do-not-include-pack-dependencies"
.
to_string
(
)
)
;
}
if
.
{
.
push
(
"--force"
.
to_string
(
)
)
;
}
}
ExtensionSubcommand
::
Uninstall
(
)
=>
{
for
in
.
.
iter
(
)
{
.
push
(
format!
(
"--uninstall-extension={id}"
)
)
;
}
}
ExtensionSubcommand
::
Update
=>
{
.
push
(
"--update-extensions"
.
to_string
(
)
)
;
}
}
}
}
#[derive(Args, Debug, Clone)]
pub
struct
ListExtensionArgs
{
#[clap(long, value_name = "category" )]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
bool
,
}
#[derive(Args, Debug, Clone)]
pub
struct
InstallExtensionArgs
{
#[clap(name = "ext-id | id" )]
pub
:
Vec
<
String
>
,
#[clap(long)]
pub
:
bool
,
#[clap(long)]
pub
:
bool
,
#[clap(long)]
pub
:
bool
,
}
#[derive(Args, Debug, Clone)]
pub
struct
UninstallExtensionArgs
{
#[clap(name = "ext-id" )]
pub
:
Vec
<
String
>
,
}
#[derive(Args, Debug, Clone)]
pub
struct
VersionArgs
{
#[clap(subcommand)]
pub
:
VersionSubcommand
,
}
#[derive(Subcommand, Debug, Clone)]
pub
enum
VersionSubcommand
{
Use
(
UseVersionArgs
)
,
Show
,
}
#[derive(Args, Debug, Clone)]
pub
struct
UseVersionArgs
{
#[clap(value_name = "stable | insiders | x.y.z | path" )]
pub
:
String
,
#[clap(long, value_name = "path" )]
pub
:
Option
<
String
>
,
}
#[derive(Args, Debug, Default, Clone)]
pub
struct
EditorOptions
{
[
clap
(
,
,
=
&
[
"file"
,
"file"
]
)
]
pub
:
Vec
<
String
>
,
#[clap(short, long, value_name = "folder" )]
pub
:
Option
<
String
>
,
#[clap(short, long, value_name = "file:line[:character]" )]
pub
:
Option
<
String
>
,
#[clap(short, long)]
pub
:
bool
,
#[clap(short, long)]
pub
:
bool
,
#[clap(short, long)]
pub
:
bool
,
#[clap(long, value_name = "locale" )]
pub
:
Option
<
String
>
,
#[clap(long, value_name = "ext-id" )]
pub
:
Vec
<
String
>
,
#[clap(flatten)]
pub
:
DesktopCodeOptions
,
}
impl
EditorOptions
{
pub
fn
add_code_args
(
&
self
,
:
&
mut
Vec
<
String
>
)
{
if
!
self
.
.
is_empty
(
)
{
.
push
(
"--diff"
.
to_string
(
)
)
;
for
in
self
.
.
iter
(
)
{
.
push
(
.
clone
(
)
)
;
}
}
if
let
Some
(
)
=
&
self
.
{
.
push
(
"--add"
.
to_string
(
)
)
;
.
push
(
.
clone
(
)
)
;
}
if
let
Some
(
)
=
&
self
.
{
.
push
(
"--goto"
.
to_string
(
)
)
;
.
push
(
.
clone
(
)
)
;
}
if
self
.
{
.
push
(
"--new-window"
.
to_string
(
)
)
;
}
if
self
.
{
.
push
(
"--reuse-window"
.
to_string
(
)
)
;
}
if
self
.
{
.
push
(
"--wait"
.
to_string
(
)
)
;
}
if
let
Some
(
)
=
&
self
.
{
.
push
(
format!
(
"--locale={locale}"
)
)
;
}
if
!
self
.
.
is_empty
(
)
{
for
in
self
.
.
iter
(
)
{
.
push
(
format!
(
"--enable-proposed-api={id}"
)
)
;
}
}
self
.
.
add_code_args
(
)
;
}
}
#[derive(Args, Debug, Default, Clone)]
pub
struct
DesktopCodeOptions
{
#[clap(long, value_name = "dir" )]
pub
:
Option
<
String
>
,
#[clap(long, value_name = "dir" )]
pub
:
Option
<
String
>
,
#[clap(long, value_name = "stable | insiders | x.y.z | path" )]
pub
:
Option
<
String
>
,
}
#[derive(Args, Debug, Clone)]
pub
struct
OutputFormatOptions
{
#[clap(value_enum, long, value_name = "format" , default_value_t = OutputFormat::Text)]
pub
:
OutputFormat
,
}
impl
DesktopCodeOptions
{
pub
fn
add_code_args
(
&
self
,
:
&
mut
Vec
<
String
>
)
{
if
let
Some
(
)
=
&
self
.
{
.
push
(
format!
(
"--extensions-dir={extensions_dir}"
)
)
;
}
if
let
Some
(
)
=
&
self
.
{
.
push
(
format!
(
"--user-data-dir={user_data_dir}"
)
)
;
}
}
}
#[derive(Args, Debug, Default, Clone)]
pub
struct
GlobalOptions
{
#[clap(long, env = "VSCODE_CLI_DATA_DIR" , global = true)]
pub
:
Option
<
String
>
,
#[clap(long, global = true)]
pub
:
bool
,
#[clap(long, global = true, hide = true)]
pub
:
Option
<
PathBuf
>
,
#[clap(long, value_enum, value_name = "level" , global = true)]
pub
:
Option
<
log::
Level
>
,
#[clap(long, global = true, hide = true)]
pub
:
bool
,
#[clap(value_enum, long, global = true, hide = true)]
pub
:
Option
<
options::
TelemetryLevel
>
,
}
impl
GlobalOptions
{
pub
fn
add_code_args
(
&
self
,
:
&
mut
Vec
<
String
>
)
{
if
self
.
{
.
push
(
"--verbose"
.
to_string
(
)
)
;
}
if
let
Some
(
)
=
self
.
{
.
push
(
format!
(
"--log={log}"
)
)
;
}
if
self
.
{
.
push
(
"--disable-telemetry"
.
to_string
(
)
)
;
}
if
let
Some
(
)
=
&
self
.
{
.
push
(
format!
(
"--telemetry-level={telemetry_level}"
)
)
;
}
}
}
#[derive(Args, Debug, Default, Clone)]
pub
struct
EditorTroubleshooting
{
#[clap(long)]
pub
:
bool
,
#[clap(long)]
pub
:
bool
,
#[clap(long, value_name = "ext-id" )]
pub
:
Vec
<
String
>
,
#[clap(value_enum, long, value_name = "on | off" )]
pub
:
Option
<
SyncState
>
,
#[clap(long, value_name = "port" )]
pub
:
Option
<
u16
>
,
#[clap(long, value_name = "port" )]
pub
:
Option
<
u16
>
,
#[clap(long)]
pub
:
bool
,
#[clap(long)]
pub
:
bool
,
}
impl
EditorTroubleshooting
{
pub
fn
add_code_args
(
&
self
,
:
&
mut
Vec
<
String
>
)
{
if
self
.
{
.
push
(
"--prof-startup"
.
to_string
(
)
)
;
}
if
self
.
{
.
push
(
"--disable-extensions"
.
to_string
(
)
)
;
}
for
in
self
.
.
iter
(
)
{
.
push
(
format!
(
"--disable-extension={id}"
)
)
;
}
if
let
Some
(
)
=
&
self
.
{
.
push
(
format!
(
"--sync={sync}"
)
)
;
}
if
let
Some
(
)
=
&
self
.
{
.
push
(
format!
(
"--inspect-extensions={port}"
)
)
;
}
if
let
Some
(
)
=
&
self
.
{
.
push
(
format!
(
"--inspect-brk-extensions={port}"
)
)
;
}
if
self
.
{
.
push
(
"--disable-gpu"
.
to_string
(
)
)
;
}
if
self
.
{
.
push
(
"--telemetry"
.
to_string
(
)
)
;
}
}
}
#[derive(ValueEnum, Clone, Copy, Debug)]
pub
enum
SyncState
{
On
,
Off
,
}
impl
fmt::
Display
for
SyncState
{
fn
fmt
(
&
self
,
:
&
mut
fmt::
Formatter
)
->
fmt::
Result
{
match
self
{
SyncState
::
Off
=>
write!
(
,
"off"
)
,
SyncState
::
On
=>
write!
(
,
"on"
)
,
}
}
}
#[derive(ValueEnum, Clone, Copy, Debug)]
pub
enum
OutputFormat
{
Json
,
Text
,
}
#[derive(Args, Clone, Debug, Default)]
pub
struct
ExistingTunnelArgs
{
#[clap(long, hide = true)]
pub
:
Option
<
String
>
,
#[clap(long, hide = true)]
pub
:
Option
<
String
>
,
#[clap(long, hide = true)]
pub
:
Option
<
String
>
,
#[clap(long, hide = true)]
pub
:
Option
<
String
>
,
}
#[derive(Args, Debug, Clone, Default)]
pub
struct
TunnelServeArgs
{
#[clap(flatten)]
pub
:
BaseServerArgs
,
#[clap(flatten, next_help_heading = Some("ADVANCED OPTIONS" ))]
pub
:
ExistingTunnelArgs
,
#[clap(long)]
pub
:
bool
,
#[clap(long)]
pub
:
bool
,
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long, hide = true)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
bool
,
#[clap(long, hide = true)]
pub
:
Option
<
String
>
,
#[clap(long, hide = true)]
pub
:
bool
,
#[clap(
long,
hide = true,
env = "VSCODE_CLI_MACHINE_STATUS" ,
action = clap::ArgAction::Set,
num_args = 0..=1,
default_value = "false" ,
default_missing_value = "true" ,
value_parser = clap::builder::BoolishValueParser::new()
)]
pub
:
bool
,
#[clap(long, hide = true)]
pub
:
bool
,
}
#[derive(Args, Debug, Clone, Default)]
pub
struct
BaseServerArgs
{
#[clap(long)]
pub
:
Vec
<
String
>
,
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
Option
<
String
>
,
#[clap(long)]
pub
:
Option
<
u32
>
,
}
impl
BaseServerArgs
{
pub
fn
apply_to
(
&
self
,
:
&
mut
CodeServerArgs
)
{
.
.
extend_from_slice
(
&
self
.
)
;
if
let
Some
(
)
=
&
self
.
{
.
=
Some
(
.
clone
(
)
)
;
}
if
let
Some
(
)
=
&
self
.
{
.
=
Some
(
.
clone
(
)
)
;
}
if
let
Some
(
)
=
self
.
{
.
=
Some
(
)
;
}
}
}
#[derive(Args, Debug, Clone)]
pub
struct
TunnelArgs
{
#[clap(subcommand)]
pub
:
Option
<
TunnelSubcommand
>
,
#[clap(flatten)]
pub
:
TunnelServeArgs
,
}
#[derive(Subcommand, Debug, Clone)]
pub
enum
TunnelSubcommand
{
Prune
,
Kill
,
Restart
,
Status
,
Rename
(
TunnelRenameArgs
)
,
Unregister
,
#[clap(subcommand)]
User
(
TunnelUserSubCommands
)
,
#[clap(subcommand)]
Service
(
TunnelServiceSubCommands
)
,
#[clap(hide = true)]
ForwardInternal
(
TunnelForwardArgs
)
,
}
#[derive(Subcommand, Debug, Clone)]
pub
enum
TunnelServiceSubCommands
{
Install
(
TunnelServiceInstallArgs
)
,
Uninstall
,
Log
,
#[clap(hide = true)]
InternalRun
,
}
#[derive(Args, Debug, Clone)]
pub
struct
TunnelServiceInstallArgs
{
#[clap(long)]
pub
:
bool
,
#[clap(long)]
pub
:
Option
<
String
>
,
}
#[derive(Args, Debug, Clone)]
pub
struct
TunnelRenameArgs
{
pub
:
String
,
}
#[derive(Args, Debug, Clone)]
pub
struct
TunnelForwardArgs
{
pub
:
Vec
<
u16
>
,
#[clap(flatten)]
pub
:
LoginArgs
,
}
#[derive(Subcommand, Debug, Clone)]
pub
enum
TunnelUserSubCommands
{
Login
(
LoginArgs
)
,
Logout
,
Show
,
}
#[derive(Args, Debug, Clone)]
pub
struct
LoginArgs
{
#[clap(long, requires = "provider" , env = "VSCODE_CLI_ACCESS_TOKEN" )]
pub
:
Option
<
String
>
,
#[clap(long, requires = "access_token" , env = "VSCODE_CLI_REFRESH_TOKEN" )]
pub
:
Option
<
String
>
,
#[clap(value_enum, long)]
pub
:
Option
<
AuthProvider
>
,
}
#[derive(clap::ValueEnum, Debug, Clone, Copy)]
pub
enum
AuthProvider
{
Microsoft
,
Github
,
}
#[cfg(test)]
mod
tests
{
use
super
::
{
Commands
,
IntegratedCli
}
;
use
clap::
Parser
;
const
MACHINE_STATUS_ENV
:
&
str
=
"VSCODE_CLI_MACHINE_STATUS"
;
fn
parse_machine_status
(
:
&
[
&
str
]
)
->
bool
{
let
=
IntegratedCli
::
try_parse_from
(
)
.
unwrap
(
)
;
let
Some
(
Commands
::
Tunnel
(
)
)
=
.
.
else
{
panic!
(
"expected tunnel arguments"
)
;
}
;
.
.
}
#[test]
fn
parses_machine_status_from_flag_and_environment
(
)
{
let
=
std:: env::
var_os
(
MACHINE_STATUS_ENV
)
;
std:: env::
remove_var
(
MACHINE_STATUS_ENV
)
;
assert!
(
!
parse_machine_status
(
&
[
"code"
,
"tunnel"
]
)
)
;
std:: env::
set_var
(
MACHINE_STATUS_ENV
,
"1"
)
;
assert!
(
parse_machine_status
(
&
[
"code"
,
"tunnel"
]
)
)
;
std:: env::
set_var
(
MACHINE_STATUS_ENV
,
"0"
)
;
assert!
(
!
parse_machine_status
(
&
[
"code"
,
"tunnel"
]
)
)
;
std:: env::
set_var
(
MACHINE_STATUS_ENV
,
"false"
)
;
assert!
(
!
parse_machine_status
(
&
[
"code"
,
"tunnel"
]
)
)
;
std:: env::
remove_var
(
MACHINE_STATUS_ENV
)
;
assert!
(
parse_machine_status
(
&
[
"code"
,
"tunnel"
,
"--machine-status"
]
)
)
;
match
{
Some
(
)
=>
std:: env::
set_var
(
MACHINE_STATUS_ENV
,
)
,
None
=>
std:: env::
remove_var
(
MACHINE_STATUS_ENV
)
,
}
}
}