Skip to content

Commit

Permalink
colorize startup banner output
Browse files Browse the repository at this point in the history
  • Loading branch information
codenoid committed Jul 30, 2024
1 parent 17010e1 commit 8c939e9
Showing 1 changed file with 23 additions and 6 deletions.
29 changes: 23 additions & 6 deletions src/LokalSo/Lokal.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,16 +228,33 @@ public function jsonSerialize(): array
];
}

private function __showStartupBanner(): void
{
printf("%s\n\n", LOKAL_SO_BANNER);
printf("Minimum Lokal Client %s\n", LOKAL_SERVER_MIN_VERSION);
private function __showStartupBanner(): void {
if (!$this->startupBanner) {
return;
}

$colors = [
'magenta' => "\033[95m",
'blue' => "\033[94m",
'cyan' => "\033[96m",
'green' => "\033[92m",
'red' => "\033[91m",
'reset' => "\033[0m"
];

$randomColor = array_rand(array_slice($colors, 0, -1)); // Exclude 'reset'
printf("%s%s%s\n\n", $colors[$randomColor], LOKAL_SO_BANNER, $colors['reset']);

printf("%sMinimum Lokal Client%s\t%s\n", $colors['red'], $colors['reset'], LOKAL_SERVER_MIN_VERSION);

if (!empty($this->address_public)) {
printf("Public Address\t\thttps://%s\n", $this->address_public);
printf("%sPublic Address%s\t\thttps://%s\n", $colors['cyan'], $colors['reset'], $this->address_public);
}

if (!empty($this->address_mdns)) {
printf("LAN Address\t\thttps://%s\n", $this->address_mdns);
printf("%sLAN Address%s\t\thttps://%s\n", $colors['green'], $colors['reset'], $this->address_mdns);
}

printf("\n");
}
};
Expand Down

0 comments on commit 8c939e9

Please sign in to comment.