Skip to content

Commit 72ed2e1

Browse files
fix(config): Improved doc comments & value formatting of options (#82)
- fix(config): User friendly value formatting of Dir and File options - docs(config): Fixed doc comment warnings <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Directory configuration now ensures directory paths include a trailing separator for consistency. * File configuration preserves file path formatting for reliable handling. * **Documentation** * Escaped special characters in date-time configuration examples for clearer documentation. <!-- end of auto-generated comment: release notes by coderabbit.ai -->
1 parent 974a3cf commit 72ed2e1

File tree

3 files changed

+14
-2
lines changed

3 files changed

+14
-2
lines changed

packages/config/lib/src/config/file_system_options.dart

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import 'dart:io';
22

33
import 'package:args/command_runner.dart';
4+
import 'package:path/path.dart' as p;
45

56
import 'options.dart';
67

@@ -17,6 +18,12 @@ class DirParser extends ValueParser<Directory> {
1718
Directory parse(final String value) {
1819
return Directory(value);
1920
}
21+
22+
@override
23+
String format(final Directory value) {
24+
final path = value.path;
25+
return path.endsWith(p.separator) ? path : '$path${p.separator}';
26+
}
2027
}
2128

2229
/// Directory path configuration option.
@@ -81,6 +88,11 @@ class FileParser extends ValueParser<File> {
8188
File parse(final String value) {
8289
return File(value);
8390
}
91+
92+
@override
93+
String format(final File value) {
94+
return value.path;
95+
}
8496
}
8597

8698
/// File path configuration option.

packages/config/lib/src/config/option_types.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ class IntOption extends ComparableValueOption<int> {
251251
///
252252
/// This implementation is more forgiving than [DateTime.parse].
253253
/// In addition to the standard T and space separators between
254-
/// date and time it also allows [-_/:t].
254+
/// date and time it also allows \[-_/:t\].
255255
class DateTimeParser extends ValueParser<DateTime> {
256256
const DateTimeParser();
257257

packages/config/lib/src/config/options.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import 'package:args/command_runner.dart';
33
import 'package:collection/collection.dart';
44
import 'package:meta/meta.dart';
55

6-
import 'configuration.dart';
6+
import 'configuration.dart' show Configuration;
77
import 'configuration_broker.dart';
88
import 'exceptions.dart';
99
import 'option_resolution.dart';

0 commit comments

Comments
 (0)