Skip to content

Commit a59b1e1

Browse files
committed
add some screenshots for cli-utils
1 parent aac00f2 commit a59b1e1

File tree

5 files changed

+33
-1
lines changed

5 files changed

+33
-1
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ composer require toolkit/cli-utils
1212

1313
![colors](./example/all-color-style.jpg)
1414

15+
## php file highlight
16+
17+
![colors](./example/cli-php-file-highlight.jpg)
18+
1519
## license
1620

1721
MIT

example/all-color-style.jpg

-54.2 KB
Loading

example/cli-php-file-highlight.jpg

49.5 KB
Loading

example/color.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@
1111
require dirname(__DIR__) . '/test/boot.php';
1212

1313
foreach (Color::getStyles() as $style) {
14-
printf(" %s: %s\n", $style, Color::apply($style, 'A message'));
14+
printf(" %s: %s\n", $style, Color::apply($style, 'This is a message'));
1515
}

src/Cli.php

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ public static function color(string $text, $style = null): string
9999
* some helpers
100100
******************************************************************************/
101101

102+
/**
103+
* @return bool
104+
*/
105+
public static function supportColor(): bool
106+
{
107+
return self::isSupportColor();
108+
}
109+
102110
/**
103111
* Returns true if STDOUT supports colorization.
104112
* This code has been copied and adapted from
@@ -123,6 +131,26 @@ public static function isSupportColor(): bool
123131
return self::isInteractive(STDOUT);
124132
}
125133

134+
/**
135+
* @return bool
136+
*/
137+
public static function isSupport256Color(): bool
138+
{
139+
return DIRECTORY_SEPARATOR === '/' && strpos(getenv('TERM'), '256color') !== false;
140+
}
141+
142+
/**
143+
* @return bool
144+
*/
145+
public static function isAnsiSupport(): bool
146+
{
147+
if (DIRECTORY_SEPARATOR === '\\') {
148+
return getenv('ANSICON') === true || getenv('ConEmuANSI') === 'ON';
149+
}
150+
151+
return true;
152+
}
153+
126154
/**
127155
* Returns if the file descriptor is an interactive terminal or not.
128156
* @param int|resource $fileDescriptor

0 commit comments

Comments
 (0)