[英]java gnu getopt - how to make it case insensitive?
I'm using gnu's getopt library for java. 我正在为Java使用gnu的getopt库。 How can I make the long opts to be case insensitive?
如何使长选择不区分大小写? ie I want
--switch
to be treated like --Switch
. 即我希望
--switch
被视为--Switch
。 The default behavior seems to be case sensitive, and I failed to find the place to define otherwise. 默认行为似乎区分大小写,并且我找不到其他定义的地方。
Thanks 谢谢
getopt is written by and (mostly) for linux CLI programs. getopt由linux CLI程序编写,并且(大多数情况下)是为linux CLI程序编写的。 Linux is a case-sensitive operating system.
Linux是区分大小写的操作系统。 In short get-opt does not supply this functionality.
简而言之,get-opt不提供此功能。 HOWEVER, you can work around this.
但是,您可以解决此问题。
Only specify options in UPPERCASE. 仅在大写中指定选项。 Before you pass your
String[]args
to getopt, loop over it and convert all options that AREN'T ARGUMENTS (eg start with - or --) to UPPERCASE. 在将
String[]args
传递给getopt之前,请对其进行循环,然后将所有没有参数的选项(例如,以-或-开头)转换为大写。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.