Skip to content

Commit bf2cb7e

Browse files
Add runs command with list and issues subcommands
- Add `runs list` command to display analysis runs for a repository - Add `runs issues` command to show issues for a specific run - Add GetAnalysisRuns and GetRunIssues API methods to client - Add GraphQL schema and queries for runs and run issues - Refactor whoami command to use boxed output format - Remove issues browse command - Add runs domain types and query helpers
1 parent a63d588 commit bf2cb7e

13 files changed

Lines changed: 3162 additions & 296 deletions

File tree

command/auth/whoami/whoami.go

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,22 +57,19 @@ func (opts *WhoAmIOptions) Run(ctx context.Context) error {
5757
fullName = "-"
5858
}
5959

60-
pterm.DefaultSection.Println("User")
61-
userSummary := [][]string{
62-
{"Name", fullName},
63-
{"Email", user.Email},
64-
{"ID", user.ID},
65-
}
66-
pterm.DefaultTable.WithData(userSummary).WithBoxed(false).Render()
60+
// Display user info with modern styling
61+
pterm.DefaultBox.WithTitle("Authenticated as").WithTitleTopCenter().Println(
62+
fmt.Sprintf("%s\n%s", pterm.Bold.Sprint(fullName), pterm.Gray(user.Email)),
63+
)
6764

6865
if len(user.Accounts) == 0 {
69-
pterm.Println("Accounts: none")
7066
return nil
7167
}
7268

69+
// Display accounts
7370
pterm.Println("")
74-
pterm.DefaultSection.Println("Accounts")
75-
accountsTable := [][]string{{"Account", "Type", "VCS", "ID"}}
71+
pterm.Println(pterm.Bold.Sprint("Connected Accounts"))
72+
accountsTable := [][]string{{"LOGIN", "TYPE", "VCS PROVIDER"}}
7673
for _, account := range user.Accounts {
7774
label := strings.TrimSpace(account.Login)
7875
if label == "" {
@@ -82,9 +79,8 @@ func (opts *WhoAmIOptions) Run(ctx context.Context) error {
8279
label,
8380
account.Type,
8481
account.VCSProvider,
85-
account.ID,
8682
})
8783
}
88-
pterm.DefaultTable.WithHasHeader(true).WithData(accountsTable).Render()
84+
pterm.DefaultTable.WithHasHeader().WithData(accountsTable).Render()
8985
return nil
9086
}

command/issues/browse/browse.go

Lines changed: 0 additions & 274 deletions
This file was deleted.

command/issues/issues.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package issues
33
import (
44
"github.com/spf13/cobra"
55

6-
"github.com/deepsourcelabs/cli/command/issues/browse"
76
"github.com/deepsourcelabs/cli/command/issues/list"
87
)
98

@@ -17,6 +16,5 @@ func NewCmdIssues() *cobra.Command {
1716
Short: "Show the list of issues in a file in a repository",
1817
}
1918
cmd.AddCommand(list.NewCmdIssuesList())
20-
cmd.AddCommand(browse.NewCmdIssuesBrowse())
2119
return cmd
2220
}

command/issues/list/list.go

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -145,14 +145,15 @@ func (opts *IssuesListOptions) Run() (err error) {
145145
return nil
146146
}
147147

148-
// Parses the SDK response and formats the data in the form of a TAB separated table
148+
// Parses the SDK response and formats the data in the form of a table
149149
// and renders it using pterm
150150
func (opts *IssuesListOptions) showIssues() {
151-
// A 2d array to contain list of issues details arrays
152-
opts.ptermTable = make([][]string, len(opts.issuesData))
151+
// Create table header
152+
header := []string{"LOCATION", "ANALYZER", "CODE", "TITLE", "CATEGORY", "SEVERITY"}
153+
data := [][]string{header}
153154

154-
// Curating the data and appending to the 2d array
155-
for index, issue := range opts.issuesData {
155+
// Add data rows
156+
for _, issue := range opts.issuesData {
156157
filePath := issue.Location.Path
157158
beginLine := issue.Location.Position.BeginLine
158159
issueLocation := fmt.Sprintf("%s:%d", filePath, beginLine)
@@ -162,10 +163,11 @@ func (opts *IssuesListOptions) showIssues() {
162163
issueCode := issue.IssueCode
163164
issueTitle := issue.IssueText
164165

165-
opts.ptermTable[index] = []string{issueLocation, analyzerShortcode, issueCode, issueTitle, issueCategory, issueSeverity}
166+
data = append(data, []string{issueLocation, analyzerShortcode, issueCode, issueTitle, issueCategory, issueSeverity})
166167
}
167-
// Using pterm to render the list of list
168-
pterm.DefaultTable.WithSeparator("\t").WithData(opts.ptermTable).Render()
168+
169+
// Render table with header
170+
pterm.DefaultTable.WithHasHeader().WithData(data).Render()
169171
}
170172

171173
// Handles exporting issues as JSON

command/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"github.com/deepsourcelabs/cli/command/issues"
1010
"github.com/deepsourcelabs/cli/command/repo"
1111
"github.com/deepsourcelabs/cli/command/report"
12+
"github.com/deepsourcelabs/cli/command/runs"
1213
"github.com/deepsourcelabs/cli/command/version"
1314
"github.com/spf13/cobra"
1415
)
@@ -45,6 +46,7 @@ Login into DeepSource using the command : deepsource auth login`,
4546
cmd.AddCommand(auth.NewCmdAuth())
4647
cmd.AddCommand(repo.NewCmdRepo())
4748
cmd.AddCommand(issues.NewCmdIssues())
49+
cmd.AddCommand(runs.NewCmdRuns())
4850
cmd.AddCommand(report.NewCmdReport())
4951

5052
return cmd

0 commit comments

Comments
 (0)