@@ -52,16 +52,16 @@ func NewCmdReport() *cobra.Command {
5252 }
5353
5454 // --repo, -r flag
55- cmd .Flags ().StringVar (& opts .Analyzer , "analyzer" , "" , "The analyzer shortcode whose test coverage is being reported " )
55+ cmd .Flags ().StringVar (& opts .Analyzer , "analyzer" , "" , "name of the analyzer to report the artifact to (example: test-coverage) " )
5656
57- cmd .Flags ().StringVar (& opts .Key , "key" , "" , "The artifact being reported.tcv for test-coverage " )
57+ cmd .Flags ().StringVar (& opts .Key , "key" , "" , "shortcode of the language (example: go) " )
5858
59- cmd .Flags ().StringVar (& opts .ValueFile , "value-file " , "" , "Path to the value file " )
59+ cmd .Flags ().StringVar (& opts .Value , "value" , "" , "value of the artifact " )
6060
61- cmd .Flags ().StringVar (& opts .Value , "value" , "" , "Value of the artifact" )
61+ cmd .Flags ().StringVar (& opts .ValueFile , "value-file " , "" , "path to the artifact value file " )
6262
6363 // --skip-verify flag to skip SSL certificate verification while reporting test coverage data.
64- cmd .Flags ().BoolVar (& opts .SkipCertificateVerification , "skip-verify" , false , "Skip SSL certificate verification while sending the test coverage data" )
64+ cmd .Flags ().BoolVar (& opts .SkipCertificateVerification , "skip-verify" , false , "skip SSL certificate verification while sending the test coverage data" )
6565
6666 return cmd
6767}
@@ -81,10 +81,10 @@ func (opts *ReportOptions) Run() int {
8181 // Command: report //
8282 /////////////////////
8383
84- reportCommandAnalyzerShortcode := opts .Analyzer
85- reportCommandKey := opts .Key
84+ reportCommandAnalyzerShortcode := strings . TrimSpace ( opts .Analyzer )
85+ reportCommandKey := strings . TrimSpace ( opts .Key )
8686 reportCommandValue := opts .Value
87- reportCommandValueFile := opts .ValueFile
87+ reportCommandValueFile := strings . TrimSpace ( opts .ValueFile )
8888
8989 // Get current path
9090 currentDir , err := os .Getwd ()
@@ -97,6 +97,38 @@ func (opts *ReportOptions) Run() int {
9797 scope .SetExtra ("currentDir" , currentDir )
9898 })
9999
100+ //////////////////
101+ // Validate Key //
102+ //////////////////
103+
104+ supportedKeys := map [string ]bool {
105+ "python" : true ,
106+ "go" : true ,
107+ "javascript" : true ,
108+ "ruby" : true ,
109+ "java" : true ,
110+ "scala" : true ,
111+ "php" : true ,
112+ "csharp" : true ,
113+ "cxx" : true ,
114+ "rust" : true ,
115+ }
116+
117+ allowedKeys := func (m map [string ]bool ) []string {
118+ keys := make ([]string , 0 , len (supportedKeys ))
119+ for k := range m {
120+ keys = append (keys , k )
121+ }
122+ return keys
123+ }
124+
125+ if ! supportedKeys [reportCommandKey ] {
126+ err = fmt .Errorf ("DeepSource | Error | Invalid Key: %s (Supported Keys: %v)" , reportCommandKey , allowedKeys (supportedKeys ))
127+ fmt .Fprintln (os .Stderr , err )
128+ sentry .CaptureException (err )
129+ return 1
130+ }
131+
100132 //////////////////
101133 // Validate DSN //
102134 //////////////////
0 commit comments