Skip to content

Commit 729adf6

Browse files
committed
format: change line length
1 parent b80829e commit 729adf6

File tree

11 files changed

+71
-28
lines changed

11 files changed

+71
-28
lines changed

lib/src/bindings/execute.dart

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ Future<int> execute(
4040
}
4141

4242
if (libraryName == null) {
43-
throw RpsException('Current platform ($platform) is currently not supported.');
43+
throw RpsException(
44+
'Current platform ($platform) is currently not supported.');
4445
}
4546

4647
final root = path.fromUri(uri.resolve(path.join('..', 'native')).path);

lib/src/cli/cli.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,13 @@ class Cli {
2222

2323
Future<void> run(List<String> arguments) async {
2424
try {
25-
final option = options.firstWhereOrNull((option) => option.match(arguments));
25+
final option =
26+
options.firstWhereOrNull((option) => option.match(arguments));
2627
if (option != null) {
2728
return option.run(this, console, arguments);
2829
}
29-
final command = commands.firstWhereOrNull((command) => command.match(arguments));
30+
final command =
31+
commands.firstWhereOrNull((command) => command.match(arguments));
3032
if (command != null) {
3133
return command.run(console, arguments);
3234
}

lib/src/cli/cli_options/help.dart

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ class HelpOption extends CliOption {
2626
@override
2727
Future<void> run(Cli cli, Console console, List<String> arguments) async {
2828
console
29-
..writeln('${bold('Run Pubspec Script')} (${boldGreen('rps')}) ${bold("v${package.version}")}')
29+
..writeln(
30+
'${bold('Run Pubspec Script')} (${boldGreen('rps')}) ${bold("v${package.version}")}')
3031
..writeln();
3132
// ..writeln('${bold('Options')}:')
3233
// ..writeln(' -v, --version - prints version.')
@@ -40,7 +41,8 @@ class HelpOption extends CliOption {
4041
final short = option.short;
4142

4243
if (short != null) {
43-
console.writeln(' -${option.short}, --${option.name} - ${option.description}');
44+
console.writeln(
45+
' -${option.short}, --${option.name} - ${option.description}');
4446
} else {
4547
console.writeln(' --${option.name} - ${option.description}');
4648
}
@@ -51,7 +53,8 @@ class HelpOption extends CliOption {
5153
if (commands.isNotEmpty) {
5254
console.writeln('${bold('Commands')}:');
5355
for (final command in commands) {
54-
console.writeln(' ${command.tooltip ?? command.name} - ${command.description}');
56+
console.writeln(
57+
' ${command.tooltip ?? command.name} - ${command.description}');
5558
}
5659
}
5760

lib/src/cli/commands/run_command.dart

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class RunCommand implements Command {
1414
}) : _getScriptsSource = getScriptsSource;
1515

1616
@override
17-
String get description => 'This runs an arbitrary command from a pubspec\'s "scripts" object. '
17+
String get description =>
18+
'This runs an arbitrary command from a pubspec\'s "scripts" object. '
1819
'If no "command" is provided, it will list the available scripts.';
1920

2021
@override
@@ -36,7 +37,9 @@ class RunCommand implements Command {
3637
final List<ExecutionEvent> events;
3738
try {
3839
/// Remove command name (run) from arguments list
39-
events = parser.getCommandsToExecute(arguments.firstOrNull == name ? arguments.skip(1).toList() : arguments);
40+
events = parser.getCommandsToExecute(arguments.firstOrNull == name
41+
? arguments.skip(1).toList()
42+
: arguments);
4043
} on ScriptParserException catch (err) {
4144
throw RpsException(err.message, err);
4245
}

lib/src/cli/console.dart

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ class Console implements StringSink {
103103
}
104104

105105
final lineLengths = lines.map((line) => visibleLength(line)).toList();
106-
final maxLength = lineLengths.fold(0, (prevLength, length) => math.max(length, prevLength));
106+
final maxLength = lineLengths.fold(
107+
0, (prevLength, length) => math.max(length, prevLength));
107108
final horizontalLength = maxLength + horizontalPadding * 2;
108109

109110
writeln(border.getTopBorder(horizontalLength));
@@ -136,7 +137,8 @@ class Console implements StringSink {
136137
paddingEnd = horizontalPadding;
137138
break;
138139
}
139-
writeln('${border.left}${border.empty * paddingStart}$line${border.empty * paddingEnd}${border.right}');
140+
writeln(
141+
'${border.left}${border.empty * paddingStart}$line${border.empty * paddingEnd}${border.right}');
140142
}
141143
for (int y = 0; y < verticalPadding; y++) {
142144
writeln(border.getEmptyLine(horizontalLength));

lib/src/scripts_parser/events/execution/command_executed.dart

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@ class CommandExecuted extends ExecutionEvent {
3636
if (arguments.isEmpty) return null;
3737

3838
return arguments.map((arg) {
39-
String escaped = arg.replaceAll(r'\', r'\\').replaceAll('"', r'\"').replaceAll("'", r"\'");
39+
String escaped = arg
40+
.replaceAll(r'\', r'\\')
41+
.replaceAll('"', r'\"')
42+
.replaceAll("'", r"\'");
4043

4144
if (escaped != arg) {
4245
return '"$escaped"';
@@ -83,23 +86,29 @@ class CommandExecuted extends ExecutionEvent {
8386

8487
final lastUsed = usedArguments.reduce(math.max);
8588
if (lastUsed > usedArguments.length) {
86-
final unusedArguments = List<int>.generate(lastUsed, (index) => index).where((e) => !usedArguments.contains(e));
89+
final unusedArguments = List<int>.generate(lastUsed, (index) => index)
90+
.where((e) => !usedArguments.contains(e));
8791

8892
throw RpsException(
8993
'The script defines unused positional argument(s): '
9094
'${unusedArguments.map((a) => '\${$a}').join(', ')}',
9195
);
9296
}
9397

94-
return [filledCommand, _serializeArguments(arguments.sublist(lastUsed + 1))].whereNotNull().join(' ');
98+
return [
99+
filledCommand,
100+
_serializeArguments(arguments.sublist(lastUsed + 1))
101+
].whereNotNull().join(' ');
95102
} else {
96103
return [command, _serializeArguments(arguments)].whereNotNull().join(' ');
97104
}
98105
}
99106

100107
@override
101108
bool operator ==(Object other) {
102-
return other is CommandExecuted && other.command == command && other.path == path;
109+
return other is CommandExecuted &&
110+
other.command == command &&
111+
other.path == path;
103112
}
104113

105114
@override

lib/src/scripts_parser/events/execution/command_referenced.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,10 @@ class CommandReferenced extends ExecutionEvent {
2222

2323
@override
2424
bool operator ==(Object other) {
25-
return other is CommandReferenced && other.command == command && other.path == path && other.label == label;
25+
return other is CommandReferenced &&
26+
other.command == command &&
27+
other.path == path &&
28+
other.label == label;
2629
}
2730

2831
@override

lib/src/scripts_parser/events/execution/hook_executed.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ class HookExecuted extends ExecutionEvent {
1919

2020
@override
2121
bool operator ==(Object other) {
22-
return other is HookExecuted && other.command == command && other.path == path && other.name == name;
22+
return other is HookExecuted &&
23+
other.command == command &&
24+
other.path == path &&
25+
other.name == name;
2326
}
2427

2528
@override

lib/src/scripts_parser/scripts_parser.dart

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,15 @@ class _ScriptParser implements ScriptsParser {
5353
);
5454
} else if (script is Map) {
5555
final platformKey = '\$${Platform.operatingSystem}';
56-
final command = script[platformKey] ?? script[ScriptsParser.defaultScriptKey];
56+
final command =
57+
script[platformKey] ?? script[ScriptsParser.defaultScriptKey];
5758
if (command is! String) {
5859
yield CommandExecuted(
5960
command: '-',
6061
context: context,
6162
description: description,
62-
error: 'No platform script key for the command: "${context.path}". '
63+
error:
64+
'No platform script key for the command: "${context.path}". '
6365
'Consider adding the key for the current '
6466
'platform: "$platformKey" or the default script '
6567
'key: "${ScriptsParser.defaultScriptKey}".',
@@ -97,11 +99,15 @@ class _ScriptParser implements ScriptsParser {
9799
}
98100

99101
final events = <ExecutionEvent>{};
100-
for (final event in _getCommandsToExecute(context: context, arguments: arguments)) {
102+
for (final event
103+
in _getCommandsToExecute(context: context, arguments: arguments)) {
101104
final added = events.add(event);
102105
if (!added) {
103106
throw ScriptParserException(
104-
'Script cycle detected: ${[...events.map((e) => e.path), event.path].join(' → ')}',
107+
'Script cycle detected: ${[
108+
...events.map((e) => e.path),
109+
event.path
110+
].join(' → ')}',
105111
);
106112
}
107113
}
@@ -144,7 +150,8 @@ class _ScriptParser implements ScriptsParser {
144150
);
145151
} else if (script is Map) {
146152
final platformKey = '\$${Platform.operatingSystem}';
147-
final command = script[platformKey] ?? script[ScriptsParser.defaultScriptKey];
153+
final command =
154+
script[platformKey] ?? script[ScriptsParser.defaultScriptKey];
148155
if (command is! String) {
149156
throw RpsException(
150157
'No platform script key for the command: "${context.path}". '

lib/src/utils/rps_package.dart

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,12 @@ class RpsConfigData {
131131

132132
static RpsConfigData fromJson(Map<String, dynamic> json) {
133133
return RpsConfigData(
134-
updateCheckedAt: json['updateCheckedAt'] != null ? DateTime.parse(json['updateCheckedAt']) : null,
135-
latestVersion: json['latestVersion'] != null ? Version.parse(json['latestVersion']) : null,
134+
updateCheckedAt: json['updateCheckedAt'] != null
135+
? DateTime.parse(json['updateCheckedAt'])
136+
: null,
137+
latestVersion: json['latestVersion'] != null
138+
? Version.parse(json['latestVersion'])
139+
: null,
136140
);
137141
}
138142

@@ -187,7 +191,9 @@ class RpsPackage {
187191
final now = DateTime.now();
188192

189193
// Return cached if valid
190-
if (cachedVersion != null && cacheDate != null && cacheDate.isSameDay(now)) {
194+
if (cachedVersion != null &&
195+
cacheDate != null &&
196+
cacheDate.isSameDay(now)) {
191197
return cachedVersion;
192198
}
193199

@@ -201,7 +207,8 @@ class RpsPackage {
201207
}
202208

203209
Future<PackageVersions> getVersions() async {
204-
final latest = await getLatestPackageVersion().timeout(const Duration(milliseconds: 300));
210+
final latest = await getLatestPackageVersion()
211+
.timeout(const Duration(milliseconds: 300));
205212

206213
return PackageVersions(
207214
latest: latest,

0 commit comments

Comments
 (0)