-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
101 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,58 @@ | ||
package org.cqfn.diktat | ||
|
||
import org.cqfn.diktat.api.DiktatLogLevel | ||
import org.cqfn.diktat.api.DiktatReporterType | ||
import org.cqfn.diktat.common.config.rules.DIKTAT_ANALYSIS_CONF | ||
import kotlinx.cli.ArgParser | ||
import kotlinx.cli.ArgType | ||
import kotlinx.cli.default | ||
|
||
fun main(args: Array<String>) { | ||
val parser = ArgParser("diktat") | ||
val configOption = parser.option( | ||
type = ArgType.String, | ||
fullName = "config", | ||
shortName = "c", | ||
description = """ | ||
Specify the location of the YAML configuration file. | ||
By default, $DIKTAT_ANALYSIS_CONF in the current | ||
directory is used. | ||
""".trimIndent(), | ||
).default(DIKTAT_ANALYSIS_CONF) | ||
val config: String by configOption | ||
|
||
val formatOption = parser.option( | ||
type = ArgType.Boolean, | ||
fullName = "format", | ||
shortName = "F", | ||
description = "Fix any deviations from the code style." | ||
).default(false) | ||
val format: Boolean by formatOption | ||
|
||
val reporterOption = parser.option( | ||
type = ArgType.Choice<DiktatReporterType>(), | ||
fullName = "reporter", | ||
shortName = "r", | ||
description = "The reporter to use", | ||
).default(DiktatReporterType.PLAIN) | ||
val reporter: DiktatReporterType by reporterOption | ||
|
||
val outputOption = parser.option( | ||
type = ArgType.String, | ||
fullName = "output", | ||
shortName = "o", | ||
description = "Redirect the reporter output to a file.", | ||
) | ||
val output: String? by outputOption | ||
|
||
val logLevelOption = parser.option( | ||
type = ArgType.Choice<DiktatLogLevel>(), | ||
fullName = "log-level", | ||
shortName = "l", | ||
description = "Enable the output of specified level", | ||
).default(DiktatLogLevel.INFO) | ||
val logLevel: DiktatLogLevel by logLevelOption | ||
|
||
parser.parse(args) | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package org.cqfn.diktat.api | ||
|
||
enum class DiktatLogLevel { | ||
DEBUG, | ||
INFO, | ||
TRACE, | ||
} |
23 changes: 23 additions & 0 deletions
23
diktat/src/main/kotlin/org/cqfn/diktat/api/DiktatReporterType.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package org.cqfn.diktat.api | ||
|
||
import kotlinx.serialization.SerialName | ||
import kotlinx.serialization.Serializable | ||
|
||
/** | ||
* Type of reporting in `diktat` | ||
*/ | ||
@Serializable | ||
enum class DiktatReporterType { | ||
@SerialName("plain") | ||
PLAIN, | ||
@SerialName("plain_group_by_file") | ||
PLAIN_GROUP_BY_FILE, | ||
@SerialName("json") | ||
JSON, | ||
@SerialName("sarif") | ||
SARIF, | ||
@SerialName("checkstyle") | ||
CHECKSTYLE, | ||
@SerialName("html") | ||
HTML, | ||
} |
3 changes: 3 additions & 0 deletions
3
diktat/src/main/kotlin/org/cqfn/diktat/cli/DiktatProperties.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
package org.cqfn.diktat.cli | ||
|
||
import org.cqfn.diktat.api.DiktatLogLevel | ||
|
||
data class DiktatProperties( | ||
val config: String, | ||
val reporter: String, | ||
val output: String, | ||
val logLevel: DiktatLogLevel, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters