Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[package:args] Add function to retrieve actual input values for command options by name. #141

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

fa0311
Copy link
Contributor

@fa0311 fa0311 commented Oct 16, 2024

  • Thanks for your contribution! Please replace this text with a description of what this PR is changing or adding and why, list any relevant issues, and review the contribution guidelines below.

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.


Add function to retrieve actual input values for command options by name.
Continuation of dart-lang/args#284

Motivation to add this.

import 'package:args/args.dart';

void main(List<String> args) {
  var parser = ArgParser();
  parser.addOption('size', abbr: 's', defaultsTo: '20');

  var results = parser.parse(args);

  var size = int.tryParse(results.option('size')!);

  if (size == null) {
    print('Could not parse the ${results.actual('size')} as an integer');
  } else {
    print('The size is $size');
  }
}
$ dart sample.dart --size aa
Could not parse the --size as an integer
$ dart sample.dart -s aa
Could not parse the -s as an integer

@fa0311 fa0311 changed the title Add function to retrieve actual input values for command options by name. [package:args] Add function to retrieve actual input values for command options by name. Oct 16, 2024
Copy link

PR Health

Breaking changes ✔️
Package Change Current Version New Version Needed Version Looking good?
args Breaking 2.6.1-wip 2.6.1-wip 2.6.1-wip ✔️
Changelog Entry ✔️
Package Changed Files

Changes to files need to be accounted for in their respective changelogs.

Coverage ✔️
File Coverage
pkgs/args/lib/src/arg_results.dart 💚 88 %
pkgs/args/lib/src/parser.dart 💚 99 %

This check for test coverage is informational (issues shown here will not fail the PR).

API leaks ✔️

The following packages contain symbols visible in the public API, but not exported by the library. Export these symbols or remove them from your publicly visible API.

Package Leaked API symbols
License Headers ✔️
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
Files
no missing headers

All source files should start with a license header.

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

Successfully merging this pull request may close these issues.

2 participants