@@ -29,6 +29,7 @@ type CreateParams struct {
2929 Summary string
3030 Body string
3131 Priority string
32+ Reporter string
3233 Assignee string
3334 Labels []string
3435 Components []string
@@ -55,7 +56,8 @@ And, this field is mandatory when creating a sub-task.`)
5556 cmd .Flags ().StringP ("summary" , "s" , "" , prefix + " summary or title" )
5657 cmd .Flags ().StringP ("body" , "b" , "" , prefix + " description" )
5758 cmd .Flags ().StringP ("priority" , "y" , "" , prefix + " priority" )
58- cmd .Flags ().StringP ("assignee" , "a" , "" , prefix + " assignee (email or display name)" )
59+ cmd .Flags ().StringP ("reporter" , "r" , "" , prefix + " reporter (username, email or display name)" )
60+ cmd .Flags ().StringP ("assignee" , "a" , "" , prefix + " assignee (username, email or display name)" )
5961 cmd .Flags ().StringArrayP ("label" , "l" , []string {}, prefix + " labels" )
6062 cmd .Flags ().StringArrayP ("component" , "C" , []string {}, prefix + " components" )
6163 cmd .Flags ().StringArray ("fix-version" , []string {}, "Release info (fixVersions)" )
@@ -185,20 +187,28 @@ func HandleNoInput(params *CreateParams) error {
185187 return nil
186188}
187189
188- // GetAssignee finds and returns assignee based on user input.
189- func GetAssignee (client * jira.Client , project string , assignee string ) string {
190- if assignee == "" {
190+ // GetRelevantUser finds and returns a valid user name or account ID based on user input.
191+ func GetRelevantUser (client * jira.Client , project string , user string ) string {
192+ if user == "" {
191193 return ""
192194 }
193-
194- user , err := api .ProxyUserSearch (client , & jira.UserSearchOptions {
195- Query : assignee ,
195+ u , err := api .ProxyUserSearch (client , & jira.UserSearchOptions {
196+ Query : user ,
196197 Project : project ,
197198 })
198- if err != nil || len (user ) == 0 {
199- cmdutil .Failed ("Unable to find assignee" )
199+ if err != nil || len (u ) == 0 {
200+ cmdutil .Failed ("Unable to find associated user for %s" , user )
201+ }
202+ return GetUserKeyForConfiguredInstallation (u [0 ])
203+ }
204+
205+ // GetUserKeyForConfiguredInstallation returns either the user name or account ID based on jira installation type.
206+ func GetUserKeyForConfiguredInstallation (user * jira.User ) string {
207+ it := viper .GetString ("installation" )
208+ if it == jira .InstallationTypeLocal {
209+ return user .Name
200210 }
201- return GetUserKeyForConfiguredInstallation ( user [ 0 ])
211+ return user . AccountID
202212}
203213
204214// GetConfiguredCustomFields returns the custom fields configured by the user.
@@ -242,12 +252,3 @@ Invalid custom fields used in the command: %s`,
242252 )
243253 }
244254}
245-
246- // GetUserKeyForConfiguredInstallation returns either the user name or account ID based on jira installation type.
247- func GetUserKeyForConfiguredInstallation (user * jira.User ) string {
248- it := viper .GetString ("installation" )
249- if it == jira .InstallationTypeLocal {
250- return user .Name
251- }
252- return user .AccountID
253- }
0 commit comments