@@ -2,7 +2,9 @@ package com.codacy.configuration.parser
22
33import java .io .File
44import caseapp ._
5- import caseapp .core .ArgParser
5+ import caseapp .core .Error
6+ import caseapp .core .app ._
7+ import caseapp .core .argparser .ArgParser
68import com .codacy .api .OrganizationProvider
79import com .codacy .configuration .parser .ConfigArgumentParsers ._
810import com .codacy .parsers .CoverageParser
@@ -108,7 +110,10 @@ case class BaseCommandConfig(
108110
109111object ConfigArgumentParsers {
110112
111- implicit val fileParser : ArgParser [File ] = ArgParser .instance(" file" )(a => Right (new File (a)))
113+ implicit val fileParser : ArgParser [File ] = new ArgParser [File ] {
114+ def apply (current : Option [File ], index : Int , span : Int , value : String ) = Right (new File (value))
115+ def description = " file"
116+ }
112117
113118 val parsersMap = Map (
114119 " cobertura" -> CoberturaParser ,
@@ -121,27 +126,38 @@ object ConfigArgumentParsers {
121126 " go" -> GoParser
122127 )
123128
124- implicit val coverageParser : ArgParser [CoverageParser ] = ArgParser .instance(" parser" ) { v =>
125- val value = v.trim.toLowerCase
126- parsersMap.get(value) match {
127- case Some (parser) => Right (parser)
128- case _ =>
129- Left (
130- s " ${value} is an unsupported/unrecognized coverage parser. (Available patterns are: ${parsersMap.keys.mkString(" ," )}) "
131- )
129+ implicit val coverageParser : ArgParser [CoverageParser ] = new ArgParser [CoverageParser ] {
130+
131+ def apply (current : Option [CoverageParser ], index : Int , span : Int , v : String ) = {
132+ val value = v.trim.toLowerCase
133+ parsersMap.get(value) match {
134+ case Some (parser) => Right (parser)
135+ case _ =>
136+ Left (
137+ Error .Other (
138+ s " ${value} is an unsupported/unrecognized coverage parser. (Available patterns are: ${parsersMap.keys.mkString(" ," )}) "
139+ )
140+ )
141+ }
132142 }
143+ def description = " parser"
133144 }
134145
135- implicit val organizationProvider : ArgParser [OrganizationProvider .Value ] =
136- ArgParser .instance(" organizationProvider" ) { v =>
146+ implicit val organizationProvider : ArgParser [OrganizationProvider .Value ] = new ArgParser [OrganizationProvider .Value ] {
147+
148+ def apply (current : Option [OrganizationProvider .Value ], index : Int , span : Int , v : String ) = {
137149 val value = v.trim.toLowerCase
138150 OrganizationProvider .values.find(_.toString == value) match {
139151 case Some (provider) => Right (provider)
140152 case _ =>
141153 Left (
142- s " ${value} is an unsupported/unrecognized organization provider. (Available organization provider are: ${OrganizationProvider .values
143- .mkString(" ," )}) "
154+ Error .Other (
155+ s " ${value} is an unsupported/unrecognized organization provider. (Available organization provider are: ${OrganizationProvider .values
156+ .mkString(" ," )}) "
157+ )
144158 )
145159 }
146160 }
161+ def description = " organizationProvider"
162+ }
147163}
0 commit comments