From a289ed12adb5ffb4dac7d832af5e1f9188766e4c Mon Sep 17 00:00:00 2001 From: Miguel de la Cruz Date: Sat, 29 Feb 2020 13:11:36 +0100 Subject: [PATCH] Adds jira username to the config --- cmd/add.go | 2 ++ cmd/token.go | 13 +++++++------ model/config.go | 5 +++-- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cmd/add.go b/cmd/add.go index d3b7dc4..f515e3f 100644 --- a/cmd/add.go +++ b/cmd/add.go @@ -32,6 +32,8 @@ func AddCmd() *cobra.Command { } func parseLine(line string) (*model.Ticket, error) { + // ToDo: it would be great to be able to relate a line with its + // parent method, at least for JS and Golang parts := strings.Split(line, ":") if len(parts) < 3 { return nil, fmt.Errorf("cannot parse line: %s", line) diff --git a/cmd/token.go b/cmd/token.go index b7a4238..2bfff0d 100644 --- a/cmd/token.go +++ b/cmd/token.go @@ -8,16 +8,16 @@ import ( func TokenSetJiraCmd() *cobra.Command { return &cobra.Command{ - Use: "jira", - Short: "Sets the value of the jira token", - Args: cobra.ExactArgs(1), - RunE: tokenSetJiraCmdF, + Use: "jira USERNAME TOKEN", + Short: "Sets the value of the jira token", + Args: cobra.ExactArgs(2), + RunE: tokenSetJiraCmdF, } } func TokenSetGithubCmd() *cobra.Command { return &cobra.Command{ - Use: "github", + Use: "github TOKEN", Short: "Sets the value of the github token", Args: cobra.ExactArgs(1), RunE: tokenSetGithubCmdF, @@ -57,7 +57,8 @@ func tokenSetJiraCmdF(cmd *cobra.Command, args []string) error { ErrorAndExit(cmd, err) } - cfg.JiraToken = args[0] + cfg.JiraUsername = args[0] + cfg.JiraToken = args[1] if err := config.SaveConfig(cfg); err != nil { ErrorAndExit(cmd, err) } diff --git a/model/config.go b/model/config.go index 6938f8e..19b8b87 100644 --- a/model/config.go +++ b/model/config.go @@ -1,6 +1,7 @@ package model type Config struct { - GithubToken string `json:"github_token"` - JiraToken string `json:"jira_token"` + GithubToken string `json:"github_token"` + JiraUsername string `json:"jira_username"` + JiraToken string `json:"jira_token"` }