Index: lib/src/arg_parser.dart |
diff --git a/lib/src/arg_parser.dart b/lib/src/arg_parser.dart |
index 49d6aa6bbf6dc4d7a965536049fd8c305e87006e..c32741df94e4115e82e8dedfa3ee75088f88aeb8 100644 |
--- a/lib/src/arg_parser.dart |
+++ b/lib/src/arg_parser.dart |
@@ -23,6 +23,10 @@ class ArgParser { |
/// The commands that have been defined for this parser. |
final Map<String, ArgParser> commands; |
+ /// A list of the [Option]s in [options] intermingled with [String] |
+ /// separators. |
+ final _optionsAndSeparators = []; |
+ |
/// Whether or not this parser parses options that appear after non-option |
/// arguments. |
final bool allowTrailingOptions; |
@@ -110,9 +114,19 @@ class ArgParser { |
} |
} |
- _options[name] = newOption(name, abbr, help, valueHelp, allowed, |
+ var option = newOption(name, abbr, help, valueHelp, allowed, |
allowedHelp, defaultsTo, callback, type, |
negatable: negatable, splitCommas: splitCommas, hide: hide); |
+ _options[name] = option; |
+ _optionsAndSeparators.add(option); |
+ } |
+ |
+ /// Adds a separator line to the usage. |
+ /// |
+ /// In the usage text for the parser, this will appear between any options |
+ /// added before this call and ones added after it. |
+ void addSeparator(String text) { |
+ _optionsAndSeparators.add(text); |
} |
/// Parses [args], a list of command-line arguments, matches them against the |
@@ -124,12 +138,12 @@ class ArgParser { |
/// |
/// This is basically the help text shown on the command line. |
@Deprecated("Replaced with get usage. getUsage() will be removed in args 1.0") |
- String getUsage() => new Usage(this).generate(); |
+ String getUsage() => usage; |
/// Generates a string displaying usage information for the defined options. |
/// |
/// This is basically the help text shown on the command line. |
- String get usage => new Usage(this).generate(); |
+ String get usage => new Usage(_optionsAndSeparators).generate(); |
/// Get the default value for an option. Useful after parsing to test if the |
/// user specified something other than the default. |