2020-02-19 05:39:54 +00:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/AlecAivazis/survey/v2"
|
|
|
|
"github.com/urfave/cli/v2"
|
2020-02-20 19:09:56 +00:00
|
|
|
"go.jolheiser.com/beaver"
|
|
|
|
"go.jolheiser.com/gpm/modules/config"
|
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,
|
|
|
|
}
|
|
|
|
|
|
|
|
func doConfig(ctx *cli.Context) error {
|
|
|
|
urlQuestion := &survey.Input{
|
|
|
|
Message: "gpm URL",
|
2020-02-20 05:46:44 +00:00
|
|
|
Default: config.GPMURL,
|
2020-02-19 05:39:54 +00:00
|
|
|
}
|
|
|
|
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
|
|
|
|
}
|