vanity/cmd/config.go

36 lines
638 B
Go

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