possible to not use long option names altogether?
irmen opened this issue · 4 comments
Hi, when defining options, is there a way to not use the long form altogether?
I tried to set fullName=null and fullName="" but the first just uses the default name as long option and the latter results in this:
--, -out [.] -> directory for output files instead of current directory { String }
(an empty option name)
Sorry, missed your issue. It seems that you try to solve another problem. You just want to use JAVA-style of options prefix. You can change it in parser settings, look at . Option should always have a full form, but prefix can be changed
I've tried your suggestion, but that didn't yield the result I was thinking of. Let me give an example:
Currently my program accepts these options:
Options:
--startEmulator, -emu -> auto-start emulator after successful compilation
--outputDir, -out [.] -> directory for output files instead of current directory { String }
--dontWriteAssembly, -noasm -> don't create assembly code
... etcetera
I'm creating the options like this:
val cli = ArgParser("prog8compiler")
val startEmulator by cli.option(ArgType.Boolean, shortName="emu", description = "auto-start emulator after successful compilation")
... etcetera
What I was wondering is if there is a way to only show the "-emu", "-out", "-noasm" options and not the "--startEmulator", "--outputDir" etcetera that are taken from the variable names. For example:
Options:
-emu -> auto-start emulator after successful compilation
-out [.] -> directory for output files instead of current directory { String }
-noasm -> don't create assembly code
... etcetera
You have several options:
Use same variable names
val cli = ArgParser("prog8compiler", prefixStyle = ArgParser.OptionPrefixStyle.JVM)
val emu by cli.option(ArgType.Boolean, description = ...)
Set custom fullName
val cli = ArgParser("prog8compiler", prefixStyle = ArgParser.OptionPrefixStyle.JVM)
val startEmulator by cli.option(ArgType.Boolean, fullName = "emu", description = ...)
Thank you . This achieves what I had in mind:
val cli = ArgParser("prog8compiler", prefixStyle = ArgParser.OptionPrefixStyle.JVM)
val startEmulator by cli.option(ArgType.Boolean, fullName = "emu", description = "auto-start emulator after successful compilation")
... etc