github.com/Azure/draft-classic@v0.16.0/cmd/draft/config_list.go (about)

     1  package main
     2  
     3  import (
     4  	"fmt"
     5  	"io"
     6  
     7  	"github.com/gosuri/uitable"
     8  	"github.com/spf13/cobra"
     9  )
    10  
    11  type configListCmd struct {
    12  	out io.Writer
    13  }
    14  
    15  func newConfigListCmd(out io.Writer) *cobra.Command {
    16  	ccmd := &configListCmd{out: out}
    17  	cmd := &cobra.Command{
    18  		Use:   "list",
    19  		Short: "list global Draft configuration stored in $DRAFT_HOME/config.toml",
    20  		RunE: func(cmd *cobra.Command, args []string) error {
    21  			return ccmd.run()
    22  		},
    23  	}
    24  	return cmd
    25  }
    26  
    27  func (ccmd *configListCmd) run() error {
    28  	table := uitable.New()
    29  	table.AddRow("KEY", "VALUE")
    30  	for k, v := range globalConfig {
    31  		table.AddRow(k, v)
    32  	}
    33  	fmt.Fprintln(ccmd.out, table)
    34  	return nil
    35  }