@@ -135,6 +135,51 @@ func NewCmdCreate(f *cmdutil.Factory, runF func(*CreateOptions) error) *cobra.Co
135135 cmd .Flags ().BoolVarP (& opts .ConfirmSubmit , "confirm" , "y" , false , "Skip the confirmation prompt" )
136136 cmd .Flags ().StringVarP (& opts .GitIgnoreTemplate , "gitignore" , "g" , "" , "Specify a gitignore template for the repository" )
137137 cmd .Flags ().StringVarP (& opts .LicenseTemplate , "license" , "l" , "" , "Specify an Open Source License for the repository" )
138+
139+ _ = cmd .RegisterFlagCompletionFunc ("gitignore" , func (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
140+ httpClient , err := opts .HttpClient ()
141+ if err != nil {
142+ return nil , cobra .ShellCompDirectiveError
143+ }
144+ cfg , err := opts .Config ()
145+ if err != nil {
146+ return nil , cobra .ShellCompDirectiveError
147+ }
148+ hostname , err := cfg .DefaultHost ()
149+ if err != nil {
150+ return nil , cobra .ShellCompDirectiveError
151+ }
152+ results , err := listGitIgnoreTemplates (httpClient , hostname )
153+ if err != nil {
154+ return nil , cobra .ShellCompDirectiveError
155+ }
156+ return results , cobra .ShellCompDirectiveNoFileComp
157+ })
158+
159+ _ = cmd .RegisterFlagCompletionFunc ("license" , func (cmd * cobra.Command , args []string , toComplete string ) ([]string , cobra.ShellCompDirective ) {
160+ httpClient , err := opts .HttpClient ()
161+ if err != nil {
162+ return nil , cobra .ShellCompDirectiveError
163+ }
164+ cfg , err := opts .Config ()
165+ if err != nil {
166+ return nil , cobra .ShellCompDirectiveError
167+ }
168+ hostname , err := cfg .DefaultHost ()
169+ if err != nil {
170+ return nil , cobra .ShellCompDirectiveError
171+ }
172+ licenses , err := listLicenseTemplates (httpClient , hostname )
173+ if err != nil {
174+ return nil , cobra .ShellCompDirectiveError
175+ }
176+ var results []string
177+ for _ , license := range licenses {
178+ results = append (results , fmt .Sprintf ("%s\t %s" , license .Key , license .Name ))
179+ }
180+ return results , cobra .ShellCompDirectiveNoFileComp
181+ })
182+
138183 return cmd
139184}
140185
@@ -225,14 +270,14 @@ func createRun(opts *CreateOptions) error {
225270 // is passed, or when the confirm flag is set.
226271 if opts .Template == "" && opts .IO .CanPrompt () && ! opts .ConfirmSubmit {
227272 if gitIgnoreTemplate == "" {
228- gt , err := interactiveGitIgnore (api . NewClientFromHTTP ( httpClient ) , host )
273+ gt , err := interactiveGitIgnore (httpClient , host )
229274 if err != nil {
230275 return err
231276 }
232277 gitIgnoreTemplate = gt
233278 }
234279 if repoLicenseTemplate == "" {
235- lt , err := interactiveLicense (api . NewClientFromHTTP ( httpClient ) , host )
280+ lt , err := interactiveLicense (httpClient , host )
236281 if err != nil {
237282 return err
238283 }
@@ -384,7 +429,7 @@ func createRun(opts *CreateOptions) error {
384429 return nil
385430}
386431
387- func interactiveGitIgnore (client * api .Client , hostname string ) (string , error ) {
432+ func interactiveGitIgnore (client * http .Client , hostname string ) (string , error ) {
388433
389434 var addGitIgnore bool
390435 var addGitIgnoreSurvey []* survey.Question
@@ -408,7 +453,7 @@ func interactiveGitIgnore(client *api.Client, hostname string) (string, error) {
408453 if addGitIgnore {
409454 var gitIg []* survey.Question
410455
411- gitIgnoretemplates , err := ListGitIgnoreTemplates (client , hostname )
456+ gitIgnoretemplates , err := listGitIgnoreTemplates (client , hostname )
412457 if err != nil {
413458 return "" , err
414459 }
@@ -429,7 +474,7 @@ func interactiveGitIgnore(client *api.Client, hostname string) (string, error) {
429474 return wantedIgnoreTemplate , nil
430475}
431476
432- func interactiveLicense (client * api .Client , hostname string ) (string , error ) {
477+ func interactiveLicense (client * http .Client , hostname string ) (string , error ) {
433478 var addLicense bool
434479 var addLicenseSurvey []* survey.Question
435480 var wantedLicense string
@@ -451,7 +496,7 @@ func interactiveLicense(client *api.Client, hostname string) (string, error) {
451496 licenseKey := map [string ]string {}
452497
453498 if addLicense {
454- licenseTemplates , err := ListLicenseTemplates (client , hostname )
499+ licenseTemplates , err := listLicenseTemplates (client , hostname )
455500 if err != nil {
456501 return "" , err
457502 }
0 commit comments