I am using this library to write cli application: https://github.com/scopt/scopt
I can run my application only inside sbt with command:
run --foo 2 -b 1
Ideally I would like to run my application in terminal like this:
myapp --foo 2 -b 1
or this script :
./myapp --foo 2 -b 1
How can I do it?
You can use sbt-assembly to create a Fat jar than then you can run like:
java -jar path/to/app.jar --foo 2 -b 1
You can also use sbt-native-packager to create an installer for your platform, after running the installer there will be a script in the PATH
that will allow you to do:
app --foo 2 -b 1
But, under the hood, this is still calling java -jar
If you do not want to need to install a JRE on your target platform you can use sbt-native-image (which under the hood uses Graal) to create a native image of your app that could be run like any other binary.
./app --foo 2 -b 1