gpm/cmd/config.go

42 lines
681 B
Go
Raw Normal View History

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