@@ -23,6 +23,7 @@ type IssuesListOptions struct {
2323 FileArg []string
2424 RepoArg string
2525 AnalyzerArg []string
26+ SeverityArg []string
2627 LimitArg int
2728 OutputFilenameArg string
2829 JSONArg bool
@@ -39,34 +40,37 @@ func NewCmdIssuesList() *cobra.Command {
3940 RepoArg : "" ,
4041 LimitArg : 30 ,
4142 }
42-
43+ // TODO:: add severity feature specifics here
4344 doc := heredoc .Docf (`
44- List issues reported by DeepSource.
45+ List issues reported by DeepSource.
46+
47+ To list issues for the current repository:
48+ %[1]s
4549
46- To list issues for the current repository:
47- %[1 ]s
50+ To list issues for a specific repository, use the %[2]s flag :
51+ %[3 ]s
4852
49- To list issues for a specific repository , use the %[2 ]s flag:
50- %[3 ]s
53+ To list issues for a specific analyzer , use the %[4 ]s flag:
54+ %[5 ]s
5155
52- To list issues for a specific analyzer , use the %[4 ]s flag:
53- %[5 ]s
56+ To limit the number of issues reported , use the %[6 ]s flag:
57+ %[7 ]s
5458
55- To limit the number of issues reported , use the %[6 ]s flag:
56- %[7 ]s
59+ To export listed issues to a file , use the %[8 ]s flag:
60+ %[9 ]s
5761
58- To export listed issues to a file, use the %[8 ]s flag:
59- %[9 ]s
62+ To export listed issues to a JSON file, use the %[10 ]s flag:
63+ %[11 ]s
6064
61- To export listed issues to a JSON file, use the %[10 ]s flag:
62- %[11 ]s
65+ To export listed issues to a CSV file, use the %[12 ]s flag:
66+ %[13 ]s
6367
64- To export listed issues to a CSV file, use the %[12 ]s flag:
65- %[13 ]s
68+ To export listed issues to a SARIF file, use the %[14 ]s flag:
69+ %[15 ]s
6670
67- To export listed issues to a SARIF file , use the %[14 ]s flag:
68- %[15 ]s
69- ` , utils .Cyan ("deepsource issues list" ), utils .Yellow ("--repo" ), utils .Cyan ("deepsource issues list --repo repo_name" ), utils .Yellow ("--analyzer" ), utils .Cyan ("deepsource issues list --analyzer python" ), utils .Yellow ("--limit" ), utils .Cyan ("deepsource issues list --limit 100" ), utils .Yellow ("--output-file" ), utils .Cyan ("deepsource issues list --output-file file_name" ), utils .Yellow ("--json" ), utils .Cyan ("deepsource issues list --json --output-file example.json" ), utils .Yellow ("--csv" ), utils .Cyan ("deepsource issues list --csv --output-file example.csv" ), utils .Yellow ("--sarif" ), utils .Cyan ("deepsource issues list --sarif --output-file example.sarif" ))
71+ To list issues for specific severities , use the %[16 ]s flag:
72+ %[17 ]s
73+ ` , utils .Cyan ("deepsource issues list" ), utils .Yellow ("--repo" ), utils .Cyan ("deepsource issues list --repo repo_name" ), utils .Yellow ("--analyzer" ), utils .Cyan ("deepsource issues list --analyzer python" ), utils .Yellow ("--limit" ), utils .Cyan ("deepsource issues list --limit 100" ), utils .Yellow ("--output-file" ), utils .Cyan ("deepsource issues list --output-file file_name" ), utils .Yellow ("--json" ), utils .Cyan ("deepsource issues list --json --output-file example.json" ), utils .Yellow ("--csv" ), utils .Cyan ("deepsource issues list --csv --output-file example.csv" ), utils .Yellow ("--sarif" ), utils .Cyan ("deepsource issues list --sarif --output-file example.sarif" ), utils . Yellow ( "--severity" ), utils . Cyan ( "deepsource issues list --severity critical --severity major " ))
7074
7175 cmd := & cobra.Command {
7276 Use : "list" ,
@@ -81,6 +85,9 @@ func NewCmdIssuesList() *cobra.Command {
8185 // --repo, -r flag
8286 cmd .Flags ().StringVarP (& opts .RepoArg , "repo" , "r" , "" , "List the issues of the specified repository" )
8387
88+ // --severity -s flag
89+ cmd .Flags ().StringArrayVarP (& opts .SeverityArg , "severity" , "s" , nil , "List issues for specified severity (CRITICAL, MAJOR, MINOR)" )
90+
8491 // --analyzer, -a flag
8592 cmd .Flags ().StringArrayVarP (& opts .AnalyzerArg , "analyzer" , "a" , nil , "List the issues for the specified analyzer" )
8693
@@ -197,7 +204,19 @@ func (opts *IssuesListOptions) getIssuesData(ctx context.Context) (err error) {
197204 // set fetched issues as issue data
198205 opts .issuesData = getUniqueIssues (fetchedIssues )
199206 }
207+ if len (opts .SeverityArg ) != 0 {
208+ //now we have some flag in the severity arg section use this and filter only those issues
209+ var fetchedIssues []issues.Issue
210+
211+ filteredIssues , err = filterIssuesBySeverity (opts .SeverityArg , opts .issuesData )
212+ if err != nil {
213+ return err
214+ }
215+ fetchedIssues = append (fetchedIssues , filteredIssues ... )
200216
217+ opts .issuesData = getUniqueIssues (fetchedIssues )
218+
219+ }
201220 return nil
202221}
203222
0 commit comments