gpm/cmd/config.go

36 lines
638 B
Go
Raw Normal View History

package cmd
import (
"github.com/AlecAivazis/survey/v2"
"github.com/urfave/cli/v2"
"go.jolheiser.com/beaver"
"go.jolheiser.com/gpm/modules/config"
)
var Config = cli.Command{
Name: "config",
Aliases: []string{"cfg"},
Usage: "Configure local gpm",
Action: doConfig,
}
func doConfig(ctx *cli.Context) error {
urlQuestion := &survey.Input{
Message: "gpm URL",
Default: config.GPMURL,
}
var urlAnswer string
if err := survey.AskOne(urlQuestion, &urlAnswer); err != nil {
return err
}
config.GPMURL = urlAnswer
if err := config.Save(); err != nil {
return err
}
beaver.Info("gpm URL saved!")
return nil
}