-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
229 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
namespace Tempest\Console; | ||
|
||
enum ConsoleOutputType | ||
{ | ||
case DEFAULT; | ||
case INFO; | ||
case ERROR; | ||
case SUCCESS; | ||
case COMMENT; | ||
case H1; | ||
case H2; | ||
|
||
public function style(string $input): string | ||
{ | ||
return match ($this) { | ||
self::INFO => ConsoleStyle::FG_DARK_BLUE($input), | ||
self::ERROR => ConsoleStyle::BOLD(ConsoleStyle::FG_WHITE(ConsoleStyle::BG_RED(ConsoleStyle::FG_WHITE($this->error($input))))), | ||
self::SUCCESS => ConsoleStyle::BOLD(ConsoleStyle::FG_DARK_GREEN($input)), | ||
self::H1 => ConsoleStyle::BOLD(ConsoleStyle::FG_WHITE(ConsoleStyle::BG_DARK_BLUE($this->header($input)))), | ||
self::H2 => ConsoleStyle::BG_BLUE($this->header($input)), | ||
self::COMMENT => ConsoleStyle::FG_GRAY($this->comment($input)), | ||
default => $input, | ||
}; | ||
} | ||
|
||
private function header(string $input): string | ||
{ | ||
return " {$input} "; | ||
} | ||
|
||
private function error(string $input): string | ||
{ | ||
return " {$input} "; | ||
} | ||
|
||
private function comment(string $input): string | ||
{ | ||
return implode( | ||
PHP_EOL, | ||
[ | ||
'/*', | ||
...array_map( | ||
fn (string $line) => "* {$line}", | ||
explode(PHP_EOL, $input), | ||
), | ||
'*/' | ||
], | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.