Hi, does anyone know how to pick the first option ...
# gradle
j
Hi, does anyone know how to pick the first option of a shell command request for input for an
exec
task? Example, the shell command spits outs a couple options to choose from. I want the task to just pick the first one or have the user be able to select. Thanks!
not kotlin but kotlin colored 1
s
More of a Gradle question than a Kotlin one. And even then, the answer probably depends more on the command you're trying to run than on Gradle itself. See if the command has a flag like
-y
for running in silent/non-interactive mode.
j
kk, i’ll ask in gradle forums. thanks!
v
I doubt a bit you get a better answer there. As Sam already said, this is more neither Kotlin nor Gradle question. Gradle cannot magically interpret your arbitrary command output and magically put any option in some arbitrary non-standard way. If possible at all, you probably have to parse the output and provide input from that or something similar.
j
i figured it out, i ran the exec as bash.
Copy code
register<Exec>("task") {
        commandLine = listOf(
            // command puts out a choice
            // so we just choose the first from the list. 
            "bash", "-c", "echo 0 | command"
        )
    }
that was enough for my usecase
thanks!
👌 1