2020-02-19 05:39:54 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
2020-10-07 04:11:36 +00:00
|
|
|
"go.jolheiser.com/gpm/config"
|
|
|
|
|
2020-02-19 05:39:54 +00:00
|
|
|
"github.com/AlecAivazis/survey/v2"
|
|
|
|
"github.com/urfave/cli/v2"
|
2020-02-20 19:09:56 +00:00
|
|
|
"go.jolheiser.com/beaver"
|
2020-02-19 05:39:54 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
var Config = cli.Command{
|
|
|
|
Name: "config",
|
|
|
|
Aliases: []string{"cfg"},
|
2020-02-19 16:48:55 +00:00
|
|
|
Usage: "Configure local gpm",
|
2020-02-19 05:39:54 +00:00
|
|
|
Action: doConfig,
|
|
|
|
}
|
|
|
|
|
2020-10-07 04:11:36 +00:00
|
|
|
func doConfig(_ *cli.Context) error {
|
|
|
|
cfg, err := config.Load()
|
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-02-19 05:39:54 +00:00
|
|
|
urlQuestion := &survey.Input{
|
|
|
|
Message: "gpm URL",
|
2020-10-07 04:11:36 +00:00
|
|
|
Default: cfg.GPMURL,
|
2020-02-19 05:39:54 +00:00
|
|
|
}
|
|
|
|
var urlAnswer string
|
|
|
|
|
|
|
|
if err := survey.AskOne(urlQuestion, &urlAnswer); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
2020-10-07 04:11:36 +00:00
|
|
|
cfg.GPMURL = urlAnswer
|
|
|
|
if err := cfg.Save(); err != nil {
|
2020-02-19 05:39:54 +00:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
beaver.Info("gpm URL saved!")
|
|
|
|
return nil
|
|
|
|
}
|