@@ -66,6 +66,10 @@ func (c *Completer) createPatchSuggestions(d prompt.Document) []prompt.Suggest {
6666 return c .getBuildVariantSuggestions (d )
6767 }
6868
69+ if getLastWord (d ) == "--param" {
70+ return c .getParamSuggestions ()
71+ }
72+
6973 if getLastWord (d ) == "--description" {
7074 return nil
7175 }
@@ -124,9 +128,18 @@ func (c *Completer) createPatchSuggestions(d prompt.Document) []prompt.Suggest {
124128 Description : "Specify the name of an existing evergreen project" ,
125129 })
126130 }
131+
132+ // it's possible to add multiple params to a single command, so the field
133+ // already existing doesn't mean we shouldn't show it.
134+ suggestions = append (suggestions , prompt.Suggest {
135+ Text : "--param" ,
136+ Description : "Specify a parameter for the evergreen patch" ,
137+ })
138+
127139 return prompt .FilterFuzzy (suggestions , d .GetWordBeforeCursor (), true )
128140
129141}
142+
130143func (c * Completer ) patchSuggestions (d prompt.Document ) []prompt.Suggest {
131144
132145 text := d .TextBeforeCursor ()
@@ -209,37 +222,51 @@ func (c *Completer) getBuildVariantSuggestions(d prompt.Document) []prompt.Sugge
209222 return prompt .FilterFuzzy (suggestions , d .GetWordBeforeCursor (), true )
210223}
211224
212- func (c * Completer ) abortPatchSuggestions ( d prompt. Document ) []prompt.Suggest {
225+ func (c * Completer ) getParamSuggestions ( ) []prompt.Suggest {
213226 var suggestions []prompt.Suggest
214- if getLastWord (d ) == "abort" {
215- suggestions = append (suggestions ,
216- prompt.Suggest {
217- Text : "--patch-id" ,
218- Description : "Patch ID of the patch to abort." ,
219- })
220- return prompt .FilterFuzzy (suggestions , d .GetWordBeforeCursor (), true )
221- }
222227
223- patches , err := c .client .GetPatches ()
224- if err != nil {
225- panic (err )
226- }
227-
228- // if we have selected a patch id already,
229- // we should stop showing other patch ids!
230- lastWord := getLastWord (d )
231- for _ , p := range patches {
232- if lastWord == p .PatchId {
233- return nil
234- }
235- }
236-
237- for _ , p := range patches {
228+ for _ , param := range c .config .Parameters {
238229 suggestions = append (suggestions , prompt.Suggest {
239- Text : p . PatchId ,
240- Description : p .Description ,
230+ Text : param . Key + "=" + param . Value ,
231+ Description : param .Description ,
241232 })
242233 }
243234
244- return prompt . FilterFuzzy ( suggestions , d . GetWordBeforeCursor (), true )
235+ return suggestions
245236}
237+
238+ //
239+ //func (c *Completer) abortPatchSuggestions(d prompt.Document) []prompt.Suggest {
240+ // var suggestions []prompt.Suggest
241+ // if getLastWord(d) == "abort" {
242+ // suggestions = append(suggestions,
243+ // prompt.Suggest{
244+ // Text: "--patch-id",
245+ // Description: "Patch ID of the patch to abort.",
246+ // })
247+ // return prompt.FilterFuzzy(suggestions, d.GetWordBeforeCursor(), true)
248+ // }
249+ //
250+ // patches, err := c.client.GetPatches()
251+ // if err != nil {
252+ // panic(err)
253+ // }
254+ //
255+ // // if we have selected a patch id already,
256+ // // we should stop showing other patch ids!
257+ // lastWord := getLastWord(d)
258+ // for _, p := range patches {
259+ // if lastWord == p.PatchId {
260+ // return nil
261+ // }
262+ // }
263+ //
264+ // for _, p := range patches {
265+ // suggestions = append(suggestions, prompt.Suggest{
266+ // Text: p.PatchId,
267+ // Description: p.Description,
268+ // })
269+ // }
270+ //
271+ // return prompt.FilterFuzzy(suggestions, d.GetWordBeforeCursor(), true)
272+ //}
0 commit comments