سؤال

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