문제

I'm using gnu's getopt library for java. How can I make the long opts to be case insensitive? i.e. I want --switch to be treated like --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. Linux is a case-sensitive operating system. In short get-opt does not supply this functionality. 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 (e.g. start with - or --) to UPPERCASE.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top