MCPcopy
hub / github.com/OpenTSDB/opentsdb / addOption

Method addOption

src/tools/ArgP.java:74–92  ·  view source on GitHub ↗

Registers an option in this argument parser. @param name The name of the option to recognize (e.g. --foo). @param meta The meta-variable to associate with the value of the option. @param help A short description of this option. @throws IllegalArgumentException if the given name was already u

(final String name,
                        final String meta,
                        final String help)

Source from the content-addressed store, hash-verified

72 * @throws IllegalArgumentException if any of the given strings is empty.
73 */
74 public void addOption(final String name,
75 final String meta,
76 final String help) {
77 if (name.isEmpty()) {
78 throw new IllegalArgumentException("empty name");
79 } else if (name.charAt(0) != '-') {
80 throw new IllegalArgumentException("name must start with a `-': " + name);
81 } else if (meta != null && meta.isEmpty()) {
82 throw new IllegalArgumentException("empty meta");
83 } else if (help.isEmpty()) {
84 throw new IllegalArgumentException("empty help");
85 }
86 final String[] prev = options.put(name, new String[] { meta, help });
87 if (prev != null) {
88 options.put(name, prev); // Undo the `put' above.
89 throw new IllegalArgumentException("Option " + name + " already defined"
90 + " in " + this);
91 }
92 }
93
94 /**
95 * Registers an option that doesn't take a value in this argument parser.

Callers 13

mainMethod · 0.95
mainMethod · 0.95
mainMethod · 0.95
mainMethod · 0.95
mainMethod · 0.95
mainMethod · 0.95
mainMethod · 0.95
UIContentExporterClass · 0.80
addCommonMethod · 0.80
addVerboseMethod · 0.80
addAutoMetricFlagMethod · 0.80
ConfigArgPMethod · 0.80

Calls 2

isEmptyMethod · 0.80
putMethod · 0.80

Tested by

no test coverage detected