So, here’s my latest .vimrc file. So far I like it. The statusline is very helpful in letting me know certain things about the file. Like what kid of file it is, character position, where I’m at in the file, and the word count, it’s useful: " Set the maximum width of text to 80 characters set textwidth=80 " Optional: visual indicator for the 80th column set colorcolumn=80 set number " formatoptions settings: " t: Auto-wrap text using textwidth " c: Auto-wrap comments using textwidth " q: Allow formatting of comments with "gq" set formatoptions+=tcq set expandtab " Use spaces instead of tabs set tabstop=4 " Number of spaces that a tab counts for set shiftwidth=4 " Number of spaces to use for each step of (auto)indent set softtabstop=4 " Number of spaces that a tab counts for while performing editing operations syntax enable " Always show the status line set laststatus=2 " Define the format (File pa...
I found the code I was looking for:
static class Args {
public static Map<String, List<String>> parseArgs(String[] args, Set<String> validArgs) {
Map<String, List<String>> map = new HashMap<>();
List<String> options = null;
for (String a : args) {
if (a.charAt(0) == '-') {
if (a.length() < 2) {
throw new IllegalArgumentException("Invalid Argument: " + a);
}
if (!validArgs.contains(a)) {
throw new IllegalArgumentException("Invalid Argument: " + a);
}
options = new ArrayList<>();
map.put(a, options);
} else if (options != null) {
options.add(a);
} else {
throw new IllegalArgumentException("Invalid Argument: " + a);
}
}
return map;
}
}
I've modified this piece of code then was in the original post. You can pass this a Set of Strings that ensure only the correct proper argumetns are being passed into the program as to not waste the programs time trying to decide if they are proper later.
Comments
Post a Comment