forked from detekt/detekt
/
GeneratorArgs.kt
78 lines (67 loc) · 2.27 KB
/
GeneratorArgs.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
package io.gitlab.arturbosch.detekt.generator
import com.beust.jcommander.Parameter
import java.nio.file.Files
import java.nio.file.Path
import java.nio.file.Paths
class GeneratorArgs {
@Parameter(
names = ["--input", "-i"],
required = true,
description = "Input paths to analyze."
)
private var input: String? = null
@Parameter(
names = ["--documentation", "-d"],
required = false,
description = "Output path for generated documentation."
)
private var documentation: String? = null
@Parameter(
names = ["--config", "-c"],
required = false,
description = "Output path for generated detekt config."
)
private var config: String? = null
@Parameter(
names = ["--cli-options"],
required = false,
description = "Output path for generated cli options page."
)
private var cliOptions: String? = null
@Parameter(
names = ["--help", "-h"],
help = true,
description = "Shows the usage."
)
var help: Boolean = false
@Parameter(
names = ["--generate-custom-rule-config", "-gcrc"],
required = false,
description = "Generate config for user-defined rules. " +
"Path to user rules can be specified with --input option"
)
var generateCustomRuleConfig: Boolean = false
val inputPath: List<Path> by lazy {
checkNotNull(input) { "Input parameter was not initialized by jcommander!" }
.splitToSequence(",", ";")
.map(String::trim)
.filter { it.isNotEmpty() }
.map { first -> Paths.get(first) }
.onEach { require(Files.exists(it)) { "Input path must exist!" } }
.toList()
}
val documentationPath: Path
get() = Paths.get(
checkNotNull(documentation) {
"Documentation output path was not initialized by jcommander!"
}
)
val configPath: Path
get() = Paths.get(checkNotNull(config) { "Configuration output path was not initialized by jcommander!" })
val cliOptionsPath: Path
get() = Paths.get(
checkNotNull(cliOptions) {
"Cli options output path was not initialized by jcommander!"
}
)
}