gpm/cmd/config.go

36 lines
644 B
Go
Raw Normal View History

package cmd
import (
"gitea.com/gpm/gpm/modules/config"
"gitea.com/jolheiser/beaver"
"github.com/AlecAivazis/survey/v2"
"github.com/urfave/cli/v2"
)
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: "gpm.jolheiser.com",
}
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
}