@@ -19,68 +19,71 @@ func NewExecutor(client *client.EvergreenClient) *Executor {
1919 return & Executor {client : client }
2020}
2121
22- func (e * Executor ) Execute ( in string ) {
23- if in == "" {
24- return
22+ func (e * Executor ) handleEvergreenPatch ( s string ) {
23+ args := [] string {
24+ "patch" , "-f" , "-y" ,
2525 }
26- if in == "quit" || in == "exit" {
27- fmt .Printf ("Bye!" )
28- os .Exit (0 )
29- }
30-
31- if strings .HasPrefix (in , "patch" ) {
3226
33- args := []string {
34- "patch" , "-f" , "-y" ,
35- }
27+ if project := flags .GetProjectValue (s ); project != "" {
28+ args = append (args , "-p" , project )
29+ } else if e .client .DefaultProject != "" {
30+ args = append (args , "-p" , e .client .DefaultProject )
31+ }
3632
37- if project := flags .GetProjectValue (in ); project != "" {
38- args = append (args , "-p" , project )
39- } else if e .client .DefaultProject != "" {
40- args = append (args , "-p" , e .client .DefaultProject )
41- }
33+ if flags .HasSpecifiedUncommitted (s ) {
34+ args = append (args , "-u" )
35+ }
4236
43- if flags .HasSpecifiedUncommitted (in ) {
44- args = append (args , "-u" )
45- }
37+ task := flags .GetTaskValue (s )
38+ if task == "" {
39+ fmt .Println ("Task must be specified!" )
40+ }
4641
47- task := flags .GetTaskValue (in )
48- if task == "" {
49- fmt .Println ("Task must be specified!" )
50- }
42+ args = append (args , "-t" , task )
5143
52- args = append (args , "-t" , task )
44+ buildvariant := flags .GetBuildVariantValue (s )
45+ if buildvariant == "" {
46+ fmt .Println ("Buildvariant must be specified!" )
47+ }
5348
54- buildvariant := flags .GetBuildVariantValue (in )
55- if buildvariant == "" {
56- fmt .Println ("Buildvariant must be specified!" )
57- }
49+ args = append (args , "-v" , buildvariant )
5850
59- args = append (args , "-v" , buildvariant )
51+ description := flags .GetDescriptionValue (s )
52+ if description == "" {
53+ description = "evergreen-prompt task"
54+ }
6055
61- description := flags .GetDescriptionValue (in )
62- if description == "" {
63- description = "evergreen-prompt task"
64- }
56+ args = append (args , "-d" , description )
6557
66- args = append (args , "-d" , description )
58+ out , err := exec .Command ("evergreen" , args ... ).Output ()
59+ if err != nil {
60+ fmt .Println (string (out ))
61+ panic (err )
62+ }
63+ fmt .Println (string (out ))
6764
68- out , err := exec .Command ("evergreen" , args ... ).Output ()
65+ if priority := flags .GetPriorityValue (s ); priority != "" {
66+ id := getPatchIdFromCliOutput (string (out ))
67+ // set priority of patch
68+ _ , err := e .client .PatchPatch (id , patch.Body {Priority : 10 })
6969 if err != nil {
70- fmt .Println (string (out ))
7170 panic (err )
7271 }
73- fmt . Println ( string ( out ))
72+ }
7473
75- if priority := flags .GetPriorityValue (in ); priority != "" {
76- id := getPatchIdFromCliOutput (string (out ))
77- // set priority of patch
78- _ , err := e .client .PatchPatch (id , patch.Body {Priority : 10 })
79- if err != nil {
80- panic (err )
81- }
82- }
74+ }
75+
76+ func (e * Executor ) Execute (in string ) {
77+ if in == "" {
78+ return
79+ }
80+ if in == "quit" || in == "exit" {
81+ fmt .Printf ("Bye!" )
82+ os .Exit (0 )
83+ }
8384
85+ if strings .HasPrefix (in , "patch" ) {
86+ e .handleEvergreenPatch (in )
8487 }
8588}
8689
0 commit comments