| 15 | } |
| 16 | |
| 17 | func NewCmdList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Command { |
| 18 | opts := &ListOptions{ |
| 19 | IO: f.IOStreams, |
| 20 | Config: f.Config, |
| 21 | } |
| 22 | |
| 23 | cmd := &cobra.Command{ |
| 24 | Use: "list", |
| 25 | Short: "List your aliases", |
| 26 | Aliases: []string{"ls"}, |
| 27 | Long: heredoc.Doc(` |
| 28 | This command prints out all of the aliases gh is configured to use. |
| 29 | `), |
| 30 | Args: cobra.NoArgs, |
| 31 | RunE: func(cmd *cobra.Command, args []string) error { |
| 32 | if runF != nil { |
| 33 | return runF(opts) |
| 34 | } |
| 35 | return listRun(opts) |
| 36 | }, |
| 37 | } |
| 38 | |
| 39 | return cmd |
| 40 | } |
| 41 | |
| 42 | func listRun(opts *ListOptions) error { |
| 43 | cfg, err := opts.Config() |