Removes --project flag
Removed the need to use --project as its value is now inferred from --epic. This commit adds an example of use to the `init` command too
This commit is contained in:
parent
dcee28eca8
commit
21c18b3095
2 changed files with 12 additions and 6 deletions
13
cmd/init.go
13
cmd/init.go
|
@ -1,6 +1,8 @@
|
|||
package cmd
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"git.ctrlz.es/mgdelacroix/campaigner/campaign"
|
||||
"git.ctrlz.es/mgdelacroix/campaigner/model"
|
||||
|
||||
|
@ -11,14 +13,18 @@ func InitCmd() *cobra.Command {
|
|||
cmd := &cobra.Command{
|
||||
Use: "init",
|
||||
Short: "Creates a new campaign in the current directory",
|
||||
Example: ` campaigner init \
|
||||
--url http://my-jira-instance.com \
|
||||
--epic ASD-27 \
|
||||
--issue-type Story \
|
||||
--summary 'Refactor {{.function}} to inject the configuration service' \
|
||||
--template ./refactor-config.tmpl`,
|
||||
Args: cobra.NoArgs,
|
||||
Run: initCmdF,
|
||||
}
|
||||
|
||||
cmd.Flags().StringP("url", "u", "", "The jira server URL")
|
||||
_ = cmd.MarkFlagRequired("url")
|
||||
cmd.Flags().StringP("project", "p", "", "The jira project key to associate the tickets with")
|
||||
_ = cmd.MarkFlagRequired("project")
|
||||
cmd.Flags().StringP("epic", "e", "", "The epic id to associate this campaign with")
|
||||
_ = cmd.MarkFlagRequired("epic")
|
||||
cmd.Flags().StringP("summary", "s", "", "The summary of the tickets")
|
||||
|
@ -32,12 +38,13 @@ func InitCmd() *cobra.Command {
|
|||
|
||||
func initCmdF(cmd *cobra.Command, _ []string) {
|
||||
url, _ := cmd.Flags().GetString("url")
|
||||
project, _ := cmd.Flags().GetString("project")
|
||||
epic, _ := cmd.Flags().GetString("epic")
|
||||
summary, _ := cmd.Flags().GetString("summary")
|
||||
template, _ := cmd.Flags().GetString("template")
|
||||
issueType, _ := cmd.Flags().GetString("issue-type")
|
||||
|
||||
project := strings.Split(epic, "-")[0]
|
||||
|
||||
cmp := &model.Campaign{
|
||||
Url: url,
|
||||
Project: project,
|
||||
|
|
|
@ -37,8 +37,6 @@ func CreateJiraTicketStandaloneCmd() *cobra.Command {
|
|||
_ = cmd.MarkFlagRequired("url")
|
||||
cmd.Flags().String("epic", "", "The jira epic id to associate the ticket with")
|
||||
_ = cmd.MarkFlagRequired("epic")
|
||||
cmd.Flags().StringP("project", "p", "", "The jira project key to associate the tickets with")
|
||||
_ = cmd.MarkFlagRequired("project")
|
||||
cmd.Flags().String("summary", "", "The summary of the ticket")
|
||||
_ = cmd.MarkFlagRequired("summary")
|
||||
cmd.Flags().String("template", "", "The template to render the description of the ticket")
|
||||
|
@ -82,7 +80,6 @@ func getVarMap(vars []string) (map[string]interface{}, error) {
|
|||
func createJiraTicketStandaloneCmdF(cmd *cobra.Command, _ []string) error {
|
||||
url, _ := cmd.Flags().GetString("url")
|
||||
epic, _ := cmd.Flags().GetString("epic")
|
||||
project, _ := cmd.Flags().GetString("project")
|
||||
username, _ := cmd.Flags().GetString("username")
|
||||
token, _ := cmd.Flags().GetString("token")
|
||||
summary, _ := cmd.Flags().GetString("summary")
|
||||
|
@ -90,6 +87,8 @@ func createJiraTicketStandaloneCmdF(cmd *cobra.Command, _ []string) error {
|
|||
vars, _ := cmd.Flags().GetStringSlice("vars")
|
||||
dryRun, _ := cmd.Flags().GetBool("dry-run")
|
||||
|
||||
project := strings.Split(epic, "-")[0]
|
||||
|
||||
if username == "" || token == "" {
|
||||
cfg, err := config.ReadConfig()
|
||||
if err != nil {
|
||||
|
|
Loading…
Reference in a new issue