@@ -13,18 +13,17 @@ import com.github.ajalt.clikt.core.subcommands
1313import com.github.ajalt.clikt.parameters.options.versionOption
1414import com.sourcegraph.scip_java.buildtools.ProcessResult
1515import com.sourcegraph.scip_java.buildtools.ProcessRunner
16- import com.sourcegraph.scip_java.commands.IndexCommand
1716import com.sourcegraph.scip_java.commands.AggregateCommand
17+ import com.sourcegraph.scip_java.commands.IndexCommand
1818import com.sourcegraph.scip_java.commands.SnapshotCommand
1919import java.nio.file.Paths
2020
2121/* *
22- * Stateful, mutable container for the scip-java CLI runtime. Tests inject
23- * a fresh environment (with redirected stdout/stderr, a temp working
24- * directory, etc.) before invoking [run].
22+ * Stateful, mutable container for the scip-java CLI runtime. Tests inject a fresh environment (with
23+ * redirected stdout/stderr, a temp working directory, etc.) before invoking [run].
2524 *
26- * Each invocation of [run] builds a fresh root clikt command tree so option
27- * state from a previous run never leaks into the next one.
25+ * Each invocation of [run] builds a fresh root clikt command tree so option state from a previous
26+ * run never leaks into the next one.
2827 */
2928class ScipJavaApp {
3029
@@ -47,13 +46,10 @@ class ScipJavaApp {
4746 fun error (message : String ) = reporter.error(message)
4847
4948 /* *
50- * Spawn an external process using the current working directory.
51- * Stdout and stderr are streamed to the env's PrintStreams line-by-line.
49+ * Spawn an external process using the current working directory. Stdout and stderr are streamed
50+ * to the env's PrintStreams line-by-line.
5251 */
53- fun runProcess (
54- command : List <String >,
55- env : Map <String , String > = emptyMap(),
56- ): ProcessResult {
52+ fun runProcess (command : List <String >, env : Map <String , String > = emptyMap()): ProcessResult {
5753 val syntax = command.joinToString(" " ) { if (' ' in it) " '$it '" else it }
5854 this .env.standardOutput.println (" $ $syntax " )
5955 return ProcessRunner .run (
@@ -99,10 +95,10 @@ class ScipJavaApp {
9995 }
10096
10197 /* *
102- * The Bazel aspect passes nested options as `--aggregate.<flag>` on
103- * `scip-java index` (e.g. `-- aggregate.allow-empty-index`). clikt forbids
104- * `.` in option names, so we rewrite the dotted prefix to `-` to match the
105- * options declared on [IndexCommand]. Tokens after `--` are left untouched.
98+ * The Bazel aspect passes nested options as `--aggregate.<flag>` on `scip-java index` (e.g.
99+ * `-- aggregate.allow-empty-index`). clikt forbids `.` in option names, so we rewrite the dotted
100+ * prefix to `-` to match the options declared on [IndexCommand]. Tokens after `--` are left
101+ * untouched.
106102 */
107103 private fun rewriteNestedOptions (args : List <String >): List <String > {
108104 var sawDoubleDash = false
@@ -113,19 +109,17 @@ class ScipJavaApp {
113109 sawDoubleDash = true
114110 arg
115111 }
116- arg.startsWith(" --aggregate." ) ->
117- " --aggregate-" + arg.removePrefix(" --aggregate." )
112+ arg.startsWith(" --aggregate." ) -> " --aggregate-" + arg.removePrefix(" --aggregate." )
118113 else -> arg
119114 }
120115 }
121116 }
122117
123118 /* *
124- * `--cwd` may appear in any position (including after the subcommand name),
125- * unlike a regular clikt parent option, so we extract it here before handing
126- * the remaining arguments to clikt and apply it to the working directory.
127- * Tokens after `--` pass through untouched so a trailing build command can
128- * legitimately contain `--cwd`.
119+ * `--cwd` may appear in any position (including after the subcommand name), unlike a regular
120+ * clikt parent option, so we extract it here before handing the remaining arguments to clikt
121+ * and apply it to the working directory. Tokens after `--` pass through untouched so a trailing
122+ * build command can legitimately contain `--cwd`.
129123 */
130124 private fun applyGlobalCwd (args : List <String >): List <String > {
131125 val result = ArrayList <String >(args.size)
@@ -163,14 +157,12 @@ class ScipJavaApp {
163157 }
164158
165159 /* *
166- * Root clikt command that plumbs the parent [ScipJavaApp] into the
167- * clikt context so subcommands can pick it up via
168- * `currentContext.findObject`.
160+ * Root clikt command that plumbs the parent [ScipJavaApp] into the clikt context so subcommands
161+ * can pick it up via `currentContext.findObject`.
169162 */
170163 private class RootCommand (val app : ScipJavaApp ) : CliktCommand(name = " scip-java" ) {
171164
172- override fun help (context : Context ) =
173- " scip-java: index Java/Kotlin codebases into SCIP."
165+ override fun help (context : Context ) = " scip-java: index Java/Kotlin codebases into SCIP."
174166
175167 private val sharedApp by findOrSetObject { app }
176168
0 commit comments