| 42 | } |
| 43 | |
| 44 | func listRun(opts *ListOptions) error { |
| 45 | client, err := opts.HTTPClient() |
| 46 | if err != nil { |
| 47 | return err |
| 48 | } |
| 49 | |
| 50 | cfg, err := opts.Config() |
| 51 | if err != nil { |
| 52 | return err |
| 53 | } |
| 54 | |
| 55 | if err := opts.IO.StartPager(); err != nil { |
| 56 | fmt.Fprintf(opts.IO.ErrOut, "starting pager failed: %v\n", err) |
| 57 | } |
| 58 | defer opts.IO.StopPager() |
| 59 | |
| 60 | hostname, _ := cfg.Authentication().DefaultHost() |
| 61 | gitIgnoreTemplates, err := api.RepoGitIgnoreTemplates(client, hostname) |
| 62 | if err != nil { |
| 63 | return err |
| 64 | } |
| 65 | |
| 66 | if len(gitIgnoreTemplates) == 0 { |
| 67 | return cmdutil.NewNoResultsError("No gitignore templates found") |
| 68 | } |
| 69 | |
| 70 | return renderGitIgnoreTemplatesTable(gitIgnoreTemplates, opts) |
| 71 | } |
| 72 | |
| 73 | func renderGitIgnoreTemplatesTable(gitIgnoreTemplates []string, opts *ListOptions) error { |
| 74 | t := tableprinter.New(opts.IO, tableprinter.WithHeader("GITIGNORE")) |