Example #1
0
)

var configCommand = &cobra.Command{
	Use:   "config",
	Short: "Configuration management",
}

var deleteConfigCommand = &cobra.Command{
	Use:   "delete <key>",
	Short: "Delete a property",
	RunE: func(cmd *cobra.Command, args []string) error {
		if len(args) == 0 {
			return errors.New("You must specify a key")
		}

		config.Delete(args[0])
		return config.Save()
	},
}

var getConfigCommand = &cobra.Command{
	Use:   "get <key>",
	Short: "Get a property",
	RunE: func(cmd *cobra.Command, args []string) error {
		if len(args) == 0 {
			return errors.New("You must specify a key")
		}

		value := config.Get(args[0])

		fmt.Println(value)
Example #2
0
package cmd

import (
	"github.com/spf13/cobra"
	"github.com/viniciuschiele/decker/config"
)

var logoutCommand = &cobra.Command{
	Use:   "logout",
	Short: "Log out from a Decker registry",
	RunE: func(cmd *cobra.Command, args []string) error {
		config.Delete("token")
		return config.Save()
	},
}

func init() {
	rootCmd.AddCommand(logoutCommand)
}