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

Clean up copy and formatting of unpack command help #4261

Merged
merged 1 commit into from
May 13, 2024
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
26 changes: 13 additions & 13 deletions lib/src/command/unpack.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,27 +31,27 @@ For example:

$topLevelProgram pub unpack foo

Downloads and extracts the latest stable package:foo from pub.dev in a
directory `foo-<version>`.
Downloads and extracts the latest stable version of package:foo from pub.dev
in a directory `foo-<version>`.

$topLevelProgram pub unpack foo:1.2.3-pre --no-resolve

Downloads and extracts package:foo version 1.2.3-pre in a directory
`foo-1.2.3-pre` without running running implicit `pub get`.
`foo-1.2.3-pre` without running implicit `pub get`.

$topLevelProgram pub unpack foo --output=archives

Downloads and extracts latest stable version of package:foo in a directory
Downloads and extracts the latest stable version of package:foo in a directory
`archives/foo-<version>`.

$topLevelProgram pub unpack 'foo:{hosted:"https://my_repo.org"}'

Downloads and extracts latest stable version of package:foo from my_repo.org
Downloads and extracts the latest stable version of package:foo from my_repo.org
in a directory `foo-<version>`.
''';

@override
String get argumentsDescription => 'package-name[:constraint]';
String get argumentsDescription => 'package-name[:descriptor]';

@override
String get docUrl => 'https://dart.dev/tools/pub/cmd/pub-unpack';
Expand All @@ -62,19 +62,19 @@ in a directory `foo-<version>`.
UnpackCommand() {
argParser.addFlag(
'resolve',
help: 'Whether to do pub get in the downloaded folder',
help: 'Whether to run pub get in the downloaded folder.',
defaultsTo: true,
hide: log.verbosity != log.Verbosity.all,
);
argParser.addFlag(
'force',
abbr: 'f',
help: 'overwrites an existing folder if it exists',
help: 'Overwrite the target directory if it already exists.',
);
argParser.addOption(
'output',
abbr: 'o',
help: 'Download and extract the package in this dir',
help: 'Download and extract the package in the specified directory.',
defaultsTo: '.',
);
}
Expand All @@ -87,15 +87,15 @@ in a directory `foo-<version>`.
@override
Future<void> runProtected() async {
if (argResults.rest.isEmpty) {
usageException('Provide a package name');
usageException('Provide a package name.');
}
if (argResults.rest.length > 1) {
usageException('Please provide only a single package name');
usageException('Provide only a single package name.');
}
final arg = argResults.rest[0];
final match = _argRegExp.firstMatch(arg);
if (match == null) {
usageException('Use the form package:constraint to specify the package.');
usageException('Use the form package:descriptor to specify the package.');
}
final parseResult = _parseDescriptor(
match.namedGroup('name')!,
Expand Down Expand Up @@ -124,7 +124,7 @@ in a directory `foo-<version>`.
deleteEntry(destinationDir);
} else {
fail(
'Target directory `$destinationDir` already exists. Use --force to overwrite',
'Target directory `$destinationDir` already exists. Use --force to overwrite.',
);
}
}
Expand Down
16 changes: 8 additions & 8 deletions test/testdata/goldens/help_test/pub unpack --help.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,29 +8,29 @@ For example:

dart pub unpack foo

Downloads and extracts the latest stable package:foo from pub.dev in a
directory `foo-<version>`.
Downloads and extracts the latest stable version of package:foo from pub.dev
in a directory `foo-<version>`.

dart pub unpack foo:1.2.3-pre --no-resolve

Downloads and extracts package:foo version 1.2.3-pre in a directory
`foo-1.2.3-pre` without running running implicit `pub get`.
`foo-1.2.3-pre` without running implicit `pub get`.

dart pub unpack foo --output=archives

Downloads and extracts latest stable version of package:foo in a directory
Downloads and extracts the latest stable version of package:foo in a directory
`archives/foo-<version>`.

dart pub unpack 'foo:{hosted:"https://my_repo.org"}'

Downloads and extracts latest stable version of package:foo from my_repo.org
Downloads and extracts the latest stable version of package:foo from my_repo.org
in a directory `foo-<version>`.


Usage: pub unpack package-name[:constraint]
Usage: pub unpack package-name[:descriptor]
-h, --help Print this usage information.
-f, --[no-]force overwrites an existing folder if it exists
-o, --output Download and extract the package in this dir
-f, --[no-]force Overwrite the target directory if it already exists.
-o, --output Download and extract the package in the specified directory.
(defaults to ".")

Run "pub help" to see global options.
Expand Down
2 changes: 1 addition & 1 deletion test/unpack_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ void main() {
await runPub(
args: ['unpack', 'foo'],
error:
'Target directory `.${s}foo-1.2.3` already exists. Use --force to overwrite',
'Target directory `.${s}foo-1.2.3` already exists. Use --force to overwrite.',
exitCode: 1,
);
await runPub(args: ['unpack', 'foo', '--force']);
Expand Down