Skip to content

Instantly share code, notes, and snippets.

@srawlins
Last active August 29, 2015 14:06
Show Gist options
  • Save srawlins/807e995e8a31be618b8e to your computer and use it in GitHub Desktop.
Save srawlins/807e995e8a31be618b8e to your computer and use it in GitHub Desktop.
Dart args SDK changes example

args/args

New class 'OptionType'

ArgParser

The 'addOption' method has a new parameter: { dart-core.String valueHelp: false }

ArgResults

The 'options' getter's comment changed:

Was: <p>Get the names of the options as an <a>dart-core.Iterable</a>.</p>

Now:

<p>Get the names of the available options as an <a>dart-core.Iterable</a>.</p>
<p>This includes the options whose values were parsed or that have defaults.
Options that weren't present and have no default will be omitted.</p>

Removed constructor 'ArgResults':

dynamic ArgResults(dart-core.Map _options, dart-core.String name, args/args.ArgResults command, dart-core.List rest)

New method 'wasParsed':

/*
 * <p>Returns <code>true</code> if the option with <a>args/args.ArgResults.wasParsed.name</a> was parsed from an actual
argument.</p>
<p>Returns <code>false</code> if it wasn't provided and the default value or no default
value would be used instead.</p>
 */
dart-core.bool wasParsed(dart-core.String name)

Option

New getter 'isFlag':

/*
 * <p>Whether the option is boolean-valued flag.</p>
 */
dart-core.bool isFlag()

New getter 'isMultiple':

/*
 * <p>Whether the option allows multiple values.</p>
 */
dart-core.bool isMultiple()

New getter 'isSingle':

/*
 * <p>Whether the option takes a single value.</p>
 */
dart-core.bool isSingle()

Removed constructor 'Option':

dynamic Option(dart-core.String name, dart-core.String abbreviation, dart-core.String help, dart-core.List allowed, dart-core.Map allowedHelp, dynamic defaultValue, dart-core.Function callback, { dart-core.bool isFlag: false }, { dart-core.bool negatable: false }, { dart-core.bool allowMultiple: true }, { dart-core.bool hide: true })

New method 'getOrDefault':

/*
 * <p>Returns <a>args/args.Option.getOrDefault.value</a> if non-<code>null</code>, otherwise returns the default value for
this option.</p>
<p>For single-valued options, it will be <a>args/args.Option.defaultValue</a> if set or <code>null</code>
otherwise. For multiple-valued options, it will be an empty list or a
list containing <a>args/args.Option.defaultValue</a> if set.</p>
 */
dynamic getOrDefault(dynamic value)

New variable: final args/args.OptionType type

New variable: final dart-core.String valueHelp

Removed variable: final dart-core.bool allowMultiple

Removed variable: final dart-core.bool isFlag

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment