From d6ddf0ef5c64cdb5262bcaba8018e6345ea391a1 Mon Sep 17 00:00:00 2001 From: Cyril Roelandt Date: Sat, 8 Dec 2018 03:58:51 +0100 Subject: Initial Launchpad bridge. This a just a preview. Not all features are expected to work. --- bridge/launchpad/config.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 bridge/launchpad/config.go (limited to 'bridge/launchpad/config.go') diff --git a/bridge/launchpad/config.go b/bridge/launchpad/config.go new file mode 100644 index 00000000..8469dbd3 --- /dev/null +++ b/bridge/launchpad/config.go @@ -0,0 +1,50 @@ +package launchpad + +import ( + "bufio" + "fmt" + "os" + "strings" + + "github.com/MichaelMure/git-bug/bridge/core" + "github.com/MichaelMure/git-bug/repository" +) + +const keyProject = "project" + +func (*Launchpad) Configure(repo repository.RepoCommon) (core.Configuration, error) { + conf := make(core.Configuration) + + projectName, err := promptProjectName() + if err != nil { + return nil, err + } + + conf[keyProject] = projectName + + return conf, nil +} + +func promptProjectName() (string, error) { + for { + fmt.Print("Launchpad project name: ") + + line, err := bufio.NewReader(os.Stdin).ReadString('\n') + if err != nil { + return "", err + } + + line = strings.TrimRight(line, "\n") + + if line == "" { + fmt.Println("Project name is empty") + continue + } + + return line, nil + } +} + +func (*Launchpad) ValidateConfig(conf core.Configuration) error { + return nil +} -- cgit