# gradle

Justin Tullgren

10/27/2023, 4:07 PM
Hi, does anyone know how to pick the first option of a shell command request for input for an
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


10/27/2023, 4:22 PM
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
for running in silent/non-interactive mode.

Justin Tullgren

10/27/2023, 4:22 PM
kk, i’ll ask in gradle forums. thanks!


10/27/2023, 7:19 PM
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.

Justin Tullgren

10/27/2023, 7:40 PM
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
👌 1