Skip to content

Commit 4dd1cc8

Browse files
committed
Fix seaneagan#73 by using package:supports_color
1 parent 1ea2a6c commit 4dd1cc8

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,11 @@
1-
# 0.4.5
1+
2+
## 0.4.6
3+
4+
Features:
5+
6+
- Improve color-support detection (#73)
7+
8+
## 0.4.5
29

310
Features:
411

lib/src/plugins/help/help.dart

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import 'package:unscripted/src/plugin.dart';
1010
import 'package:unscripted/src/usage.dart';
1111
import 'package:unscripted/src/util.dart';
1212
import 'package:quiver/strings.dart';
13+
import 'package:supports_color/supports_color.dart';
1314

1415
import 'option_help.dart';
1516
import 'pens.dart';
@@ -79,7 +80,7 @@ class Help extends Plugin {
7980
}
8081

8182
UsageFormatter _getUsageFormatter(Usage usage, bool isWindows) =>
82-
new TerminalUsageFormatter(usage, shouldDisableColor(isWindows));
83+
new TerminalUsageFormatter(usage, supportsColor);
8384

8485
List<String> _getHelpPath(CommandInvocation commandInvocation) {
8586
var path = [];
@@ -102,6 +103,3 @@ class Help extends Plugin {
102103
}
103104

104105
}
105-
106-
// TODO: May need to also disable when testing help formatting output.
107-
bool shouldDisableColor(bool isWindows) => isWindows; // || !stdout.hasTerminal;

lib/src/plugins/help/usage_formatter.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class TerminalUsageFormatter extends UsageFormatter {
2121

2222
var oldColorDisabled = color_disabled;
2323

24-
color_disabled = color;
24+
color_disabled = !color;
2525

2626
var parser = usage.parser;
2727
var description = usage.description;

pubspec.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: unscripted
2-
version: 0.4.5
2+
version: 0.4.6
33
author: Sean Eagan <[email protected]>
44
description: Declarative command-line interface programming.
55
homepage: http://github.com/seaneagan/unscripted
@@ -10,5 +10,6 @@ dependencies:
1010
mockable_filesystem: any
1111
path: any
1212
quiver: any
13+
supports_color: any
1314
dev_dependencies:
1415
unittest: any

0 commit comments

Comments
 (0)