Tahir Raza
06/28/2023, 12:22 PMLandry Norris
06/28/2023, 12:31 PMVampire
06/28/2023, 12:31 PMJoffrey
06/28/2023, 12:32 PM--args
gradlew argument is actually meant to pass the args to the applicationVampire
06/28/2023, 12:32 PM--args
the part after it is indeed given as argument to the class run by the run
task.Adam S
06/28/2023, 12:34 PM./gradlew :app:run —args='—stage=prod'
doesn’t use a regular -
dash, it uses —
which is an em-dash or maybe a minus?Tahir Raza
06/28/2023, 12:36 PMVampire
06/28/2023, 12:36 PMTahir Raza
06/28/2023, 12:36 PMVampire
06/28/2023, 12:40 PMVampire
06/28/2023, 12:41 PM--scan
if you canTahir Raza
06/28/2023, 12:44 PMTahir Raza
06/28/2023, 12:45 PM./gradlew :app:run --args='--stage=prod'
> Task :app:run FAILED
Unknown option --stage=prod
Usage: producer-service options_list
Options:
--stage, -s -> stage of the application { String }
--help, -h -> Usage info
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:run'.
> Process 'command '/Library/Java/JavaVirtualMachines/corretto-17.0.7/Contents/Home/bin/java'' finished with non-zero exit value 127
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
* Get more help at <https://help.gradle.org>
BUILD FAILED in 857ms
9 actionable tasks: 4 executed, 5 up-to-date
Adam S
06/28/2023, 12:50 PM--stage
?
./gradlew :app:run --args='--stage prod'
There’s not any examples of how to correctly pass a kotlinx-cli args, which doesn’t help https://github.com/Kotlin/kotlinx-cli/issues/94Joffrey
06/28/2023, 12:52 PMkotlinx-cli
is not really developed at the moment, so you won't find much help around it. I would really suggest you give a try to Clikt instead, which is actively developed and has a ton of useful features (and nice design overall)Joffrey
06/28/2023, 12:54 PM--key value
with a space instead of =
, as @Adam S suggestedVampire
06/28/2023, 1:01 PM./gradlew :app:run --args=--stage --args=prod
otherwise you get one argument supplied including the space instead of two argumentsJoffrey
06/28/2023, 1:03 PMSince Gradle 4.9, the command line arguments can be passed with --args. For example, if you want to launch the application with command line argumentsAnd then in JavaExec.setArgsString:, you can usefoo --bar
(seegradle run --args="foo --bar"
).JavaExec.setArgsString(java.lang.String)
Parses an argument list from args and passes it to setArgs(List).
The parser supports both single quote (') and double quote (") as quote delimiters. For example, to pass the argument foo bar, use "foo bar".
Note: the parser does not support using backslash to escape quotes. If this is needed, use the other quote delimiter around it. For example, to pass the argument 'singly quoted', use "'singly quoted'".
Vampire
06/28/2023, 1:26 PM--args="'foo bar'"
to give it as one argument, so it should indeed be --args="--stage prod"
Tahir Raza
06/28/2023, 1:46 PM--args="'foo bar'"
I would have never guessed it thanks a lot