2020-02-19 05:39:54 +00:00
|
|
|
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"},
|
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",
|
|
|
|
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
|
|
|
|
}
|