| 18 | } |
| 19 | |
| 20 | func NewCmdConfigList(f *cmdutil.Factory, runF func(*ListOptions) error) *cobra.Command { |
| 21 | opts := &ListOptions{ |
| 22 | IO: f.IOStreams, |
| 23 | Config: f.Config, |
| 24 | } |
| 25 | |
| 26 | cmd := &cobra.Command{ |
| 27 | Use: "list", |
| 28 | Short: "Print a list of configuration keys and values", |
| 29 | Aliases: []string{"ls"}, |
| 30 | Args: cobra.ExactArgs(0), |
| 31 | RunE: func(cmd *cobra.Command, args []string) error { |
| 32 | if runF != nil { |
| 33 | return runF(opts) |
| 34 | } |
| 35 | |
| 36 | return listRun(opts) |
| 37 | }, |
| 38 | } |
| 39 | |
| 40 | cmd.Flags().StringVarP(&opts.Hostname, "host", "h", "", "Get per-host configuration") |
| 41 | |
| 42 | return cmd |
| 43 | } |
| 44 | |
| 45 | func listRun(opts *ListOptions) error { |
| 46 | cfg, err := opts.Config() |