private static List<Option> parseDefaults(final String doc) { final List<Option> defaults = list(); for (String s : parseSection("options:", doc)) {
private static List<Option> parseDefaults(final String doc) { final List<Option> defaults = list(); for (String s : parseSection("options:", doc)) {
/** * Constructs an argument parser from a POSIX-style help message. * * @param doc * a POSIX-style help message * @throws DocoptLanguageError * if the help message is malformed * @see Docopt */ public Docopt(final String doc) { this.doc = doc; final List<String> usageSections = parseSection("usage:", doc); if (usageSections.size() == 0) { throw new DocoptLanguageError( "\"usage:\" (case-insensitive) not found."); } if (usageSections.size() > 1) { throw new DocoptLanguageError( "More than one \"usage:\" (case-insensitive)."); } usage = usageSections.get(0); options = parseDefaults(doc); pattern = parsePattern(formalUsage(usage), options); }
/** * Constructs an argument parser from a POSIX-style help message. * * @param doc * a POSIX-style help message * @throws DocoptLanguageError * if the help message is malformed * @see Docopt */ public Docopt(final String doc) { this.doc = doc; final List<String> usageSections = parseSection("usage:", doc); if (usageSections.size() == 0) { throw new DocoptLanguageError( "\"usage:\" (case-insensitive) not found."); } if (usageSections.size() > 1) { throw new DocoptLanguageError( "More than one \"usage:\" (case-insensitive)."); } usage = usageSections.get(0); options = parseDefaults(doc); pattern = parsePattern(formalUsage(usage), options); }