config

package
v0.1.43 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 4, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NewConfigGetCmd = &cobra.Command{
	Use:   "get",
	Short: "Get tran configuration",
	Long:  "Get tran configuration",
	RunE: func(cmd *cobra.Command, args []string) error {
		if err != nil {
			return err
		}

		viper.SetConfigType("yaml")

		viper.ReadConfig(bytes.NewBuffer(tranConfig))

		fmt.Println(viper.Get("config." + args[0]))

		return nil
	},
}
View Source
var NewConfigListCmd = &cobra.Command{
	Use:   "list",
	Short: "List tran configuration",
	Long:  "List tran configuration",
	RunE: func(cmd *cobra.Command, args []string) error {
		if err != nil {
			return err
		}

		viper.SetConfigType("yaml")

		viper.ReadConfig(bytes.NewBuffer(tranConfig))

		config := viper.GetStringMap("config")

		for k, v := range config {
			fmt.Println(k+" =", v)
		}

		return nil
	},
}
View Source
var NewConfigSetCmd = &cobra.Command{
	Use:   "set",
	Short: "Update tran configuration",
	Long:  "Update tran configuration, such as editor, show updates, etc.",
	RunE: func(cmd *cobra.Command, args []string) error {
		if err != nil {
			return err
		}

		viper.SetConfigType("yaml")

		viper.ReadConfig(bytes.NewBuffer(tranConfig))

		viper.Set("config."+args[0], args[1])

		err := viper.WriteConfigAs(tranConfigPath)

		if err != nil {
			return err
		}

		fmt.Println(ansi.Color("Updated tran configuration", "green"))

		return nil
	},
}

Functions

func NewConfigCmd

func NewConfigCmd() *cobra.Command

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL