xenomachina / kotlin-argparser

Easy to use and concise yet powerful and robust command line argument parsing for Kotlin
GNU Lesser General Public License v2.1
485 stars 33 forks source link

Can someone provide an example of an optional argument? #35

Closed ilovemysillybanana closed 6 years ago

ilovemysillybanana commented 6 years ago

How would one go about adding optional arguments.

package platform.args

import com.xenomachina.argparser.ArgParser

class ArgsProcess(parser: ArgParser) {

    val data by parser.storing("-s", "--settings",
            help = "path to the settings file")

    val version by parser.flagging("-v", "--version",
            help="Prints out the version of the program")
}

My program is currently crashing out if I don't specify the settings file. Sorry, I have read the read me but I might have missed this or misunderstood. It looks as though you do support optional arguments, but I don't understand how they are declared as such.

ilovemysillybanana commented 6 years ago

Nevermind, it was a problem with my IDE. It was not importing this line:

import com.xenomachina.argparser.default