Skip to content

Commit

Permalink
issue list - add parent information
Browse files Browse the repository at this point in the history
  • Loading branch information
3ximus committed Mar 20, 2024
1 parent b4dee81 commit 311e103
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,7 @@ bb help [COMMAND]
- issue list - add way to sort by recent or the ones the user has participated on
- issue log - is broken, and doesn't use current branch as issue key
- issue edit - edit issue title and maybe some tags
- View/Edit issue checklist
- pr list - add timings information with a flag
16 changes: 14 additions & 2 deletions api/jira-types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,18 @@ type JiraIssue struct {
Id string
}
Parent struct {
Key string `json:"key"`
Fields struct {
Summary string
Type struct {
Name string
Subtask bool
} `json:"issuetype"`
Priority struct {
Name string
Id string
}
}
}
Project struct {
Name string
Expand Down Expand Up @@ -59,8 +71,8 @@ type JiraIssue struct {
type UpdateIssueRequestBody struct {
Fields struct {
// This on might be enough when set on project
TimeTracking *TimeTracking `json:"timetracking,omitempty"`
Summary string `json:"summary,omitempty"`
TimeTracking *TimeTracking `json:"timetracking,omitempty"`
Summary string `json:"summary,omitempty"`
} `json:"fields,omitempty"`
Update struct {
TimeTracking []UpdateType[TimeTracking] `json:"timetracking,omitempty"`
Expand Down
15 changes: 12 additions & 3 deletions cmd/issue/list.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ var ListCmd = &cobra.Command{
priority, _ := cmd.Flags().GetBool("priority")
showUsers, _ := cmd.Flags().GetBool("users")
showTime, _ := cmd.Flags().GetBool("time")
showParents, _ := cmd.Flags().GetBool("parent")

project := ""
if len(args) == 0 {
Expand Down Expand Up @@ -76,13 +77,20 @@ var ListCmd = &cobra.Command{
timeSpent = issue.Fields.TimeTracking.TimeSpent
}
util.Printf("%s \033[1;32m%s\033[m %s %s %s\n", util.FormatIssueStatus(issue.Fields.Status.Name), issue.Key, util.FormatIssueType(issue.Fields.Type.Name), issue.Fields.Summary, util.FormatIssuePriority(issue.Fields.Priority.Id, issue.Fields.Priority.Name))
if showParents {
if issue.Fields.Parent.Fields.Summary != "" {
util.Printf(" \033[37mParent:\033[m %s %s (\033[37m%s\033[m)\n", util.FormatIssueType(issue.Fields.Parent.Fields.Type.Name), issue.Fields.Parent.Fields.Summary, issue.Fields.Parent.Key)
} else {
util.Printf(" \033[37mParent: ---\n")
}
}
if showUsers {
if all {
util.Printf(" \033[37mAssigned: \033[1m%s\033[0;37m -> Reporter: \033[1;36m%s\033[m \033[37m(%d comments)\033[m\n", issue.Fields.Assignee.DisplayName, issue.Fields.Reporter.DisplayName, issue.Fields.Comment.Total)
util.Printf(" \033[37mAssigned: \033[1m%s\033[0;37m -> Reporter: \033[1;36m%s\033[m \033[m\033[37m(%d comments)\033[m\n", issue.Fields.Assignee.DisplayName, issue.Fields.Reporter.DisplayName, issue.Fields.Comment.Total)
} else if reporter {
util.Printf(" \033[37mAssigned: \033[1m%s \033[37m(%d comments)\033[m\n", issue.Fields.Assignee.DisplayName, issue.Fields.Comment.Total)
util.Printf(" \033[37mAssigned: \033[1m%s \033[m\033[37m(%d comments)\033[m\n", issue.Fields.Assignee.DisplayName, issue.Fields.Comment.Total)
} else {
util.Printf(" \033[37mReporter: \033[1m%s \033[37m(%d comments)\033[m\n", issue.Fields.Reporter.DisplayName, issue.Fields.Comment.Total)
util.Printf(" \033[37mReporter: \033[1m%s \033[m\033[37m(%d comments)\033[m\n", issue.Fields.Reporter.DisplayName, issue.Fields.Comment.Total)
}
}
if showTime {
Expand All @@ -107,6 +115,7 @@ func init() {
// display
ListCmd.Flags().BoolP("users", "u", false, "show users")
ListCmd.Flags().BoolP("time", "t", false, "show time information")
ListCmd.Flags().BoolP("parent", "p", true, "show parent tickets")
ListCmd.Flags().IntP("number-results", "n", 10, "max number of results retrieve")
// sort
ListCmd.Flags().BoolP("priority", "P", false, "sort by priority")
Expand Down
5 changes: 5 additions & 0 deletions cmd/issue/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ var ViewCmd = &cobra.Command{
util.Printf("%s \033[1;32m%s\033[m %s %s %s\n", util.FormatIssueStatus(issue.Fields.Status.Name), issue.Key, util.FormatIssueType(issue.Fields.Type.Name), issue.Fields.Summary, util.FormatIssuePriority(issue.Fields.Priority.Id, issue.Fields.Priority.Name))
util.Printf(" Assigned: \033[1;33m%s\033[m -> Reporter: \033[1;36m%s\033[m \033[37m(%d comments)\n", issue.Fields.Assignee.DisplayName, issue.Fields.Reporter.DisplayName, issue.Fields.Comment.Total)
util.Printf(" Time spent: \033[1;34m%s\033[m [ %s/%s ]\n", timeSpent, issue.Fields.TimeTracking.RemainingEstimate, issue.Fields.TimeTracking.OriginalEstimate)
if issue.Fields.Parent.Fields.Summary != "" {
util.Printf(" \033[37mParent:\033[m %s %s (\033[37m%s\033[m)\n", util.FormatIssueType(issue.Fields.Parent.Fields.Type.Name), issue.Fields.Parent.Fields.Summary, issue.Fields.Parent.Key)
} else {
util.Printf(" \033[37mParent: ---\n")
}
fmt.Println()

web, _ := cmd.Flags().GetBool("web")
Expand Down
5 changes: 3 additions & 2 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ var cfgFile string

var RootCmd = &cobra.Command{
Use: "bb",
Short: "bb is a bitbucket cli",
Long: `Bitbucket cli to interact with bitbucket.org`,
Short: "CLI utility to manage Bitbucket repositories and Jira organizations",
Long: `This utility is focused on allowing simple operations on bitbucket and jira through the command line.
It provides commands to operate on Bitbucket and Jira.`,
}

// Execute adds all child commands to the root command and sets flags appropriately.
Expand Down

0 comments on commit 311e103

Please sign in to comment.