| 24 | } |
| 25 | |
| 26 | func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Command { |
| 27 | opts := &ListOptions{ |
| 28 | IO: f.IOStreams, |
| 29 | Config: f.Config, |
| 30 | HTTPClient: f.HttpClient, |
| 31 | } |
| 32 | |
| 33 | cmd := &cobra.Command{ |
| 34 | Use: "list", |
| 35 | Short: "Lists SSH keys in your GitHub account", |
| 36 | Aliases: []string{"ls"}, |
| 37 | Args: cobra.ExactArgs(0), |
| 38 | RunE: func(cmd *cobra.Command, args []string) error { |
| 39 | if runF != nil { |
| 40 | return runF(opts) |
| 41 | } |
| 42 | return listRun(opts) |
| 43 | }, |
| 44 | } |
| 45 | |
| 46 | return cmd |
| 47 | } |
| 48 | |
| 49 | func listRun(opts *ListOptions) error { |
| 50 | apiClient, err := opts.HTTPClient() |