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

update readme; add contributing doc #237

Merged
merged 2 commits into from
Mar 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 2.4.1-dev

* Add a `CONTRIBUTING.md` file; move the publishing automation docs from the
readme into the contributing doc.

## 2.4.0

* Command suggestions will now also suggest based on aliases of a command.
Expand Down
56 changes: 56 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# How to Contribute

We'd love to accept your patches and contributions to this project. There are
just a few small guidelines you need to follow.

## Contributor License Agreement

Contributions to this project must be accompanied by a Contributor License
Agreement (CLA). You (or your employer) retain the copyright to your
contribution; this simply gives us permission to use and redistribute your
contributions as part of the project. Head over to
<https://cla.developers.google.com/> to see your current agreements on file or
to sign a new one.

You generally only need to submit a CLA once, so if you've already submitted one
(even if it was for a different project), you probably don't need to do it
again.

## Code Reviews

All submissions, including submissions by project members, require review. We
use GitHub pull requests for this purpose. Consult
[GitHub Help](https://help.github.com/articles/about-pull-requests/) for more
information on using pull requests.

## Coding style

The Dart source code in this repo follows the:

* [Dart style guide](https://dart.dev/guides/language/effective-dart/style)

You should familiarize yourself with those guidelines.

## File headers

All files in the Dart project must start with the following header; if you add a
new file please also add this. The year should be a single number stating the
year the file was created (don't use a range like "2011-2012"). Additionally, if
you edit an existing file, you shouldn't update the year.

// Copyright (c) 2023, 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.

## Publishing automation

For information about our publishing automation and release process, see
https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

## Community Guidelines

This project follows
[Google's Open Source Community Guidelines](https://opensource.google/conduct/).

We pledge to maintain an open and welcoming environment. For details, see our
[code of conduct](https://dart.dev/code-of-conduct).
16 changes: 4 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ print(results['mode']); // prints '[on, off]'

This can be disabled by passing `splitCommas: false`.

## Defining commands ##
## Defining commands

In addition to *options*, you can also define *commands*. A command is a named
argument that has its own set of options. For example, consider this shell
Expand Down Expand Up @@ -295,7 +295,6 @@ e.g.
File `dgit.dart`

```dart

void main(List<String> args){
var runner = CommandRunner("dgit", "A dart implementation of distributed version control.")
..addCommand(CommitCommand())
Expand All @@ -305,11 +304,8 @@ void main(List<String> args){

When the above `run(args)` line executes it parses the command line args looking for one of the commands (`commit` or `stash`).



If the [CommandRunner][] finds a matching command then the [CommandRunner][] calls the overridden `run()` method on the matching command (e.g. CommitCommand().run).


Commands are defined by extending the [Command][] class. For example:

```dart
Expand All @@ -333,13 +329,15 @@ class CommitCommand extends Command {
}
}
```

### CommandRunner Arguments
The [CommandRunner][] allows you to specify both global args as well as command specific arguments (and even sub-command specific arguments).

#### Global Arguments
Add argments directly to the [CommandRunner] to specify global arguments:

Adding global arguments

```dart
var runner = CommandRunner('dgit', "A dart implementation of distributed version control.");
// add global flag
Expand All @@ -350,14 +348,13 @@ runner.argParser.addFlag('verbose', abbr: 'v', help: 'increase logging');
Add arguments to each [Command][] to specify [Command][] specific arguments.

```dart

CommitCommand() {
// we can add command specific arguments here.
// [argParser] is automatically created by the parent class.
argParser.addFlag('all', abbr: 'a');
}

```

### SubCommands

Commands can also have subcommands, which are added with [addSubcommand][]. A
Expand Down Expand Up @@ -443,11 +440,6 @@ The resulting string looks something like this:
[ia32] Intel x86
```

## Publishing automation

For information about our publishing automation and release process, see
https://github.com/dart-lang/ecosystem/wiki/Publishing-automation.

[posix]: https://pubs.opengroup.org/onlinepubs/009695399/basedefs/xbd_chap12.html#tag_12_02
[gnu]: https://www.gnu.org/prep/standards/standards.html#Command_002dLine-Interfaces
[ArgParser]: https://pub.dev/documentation/args/latest/args/ArgParser/ArgParser.html
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: args
version: 2.4.0
version: 2.4.1-dev
description: >-
Library for defining parsers for parsing raw command-line arguments into a set
of options and values using GNU and POSIX style options.
Expand Down