From 6529b7095e1a296e57f468b14331979715fa1a89 Mon Sep 17 00:00:00 2001 From: "leedongmyung[desktop]" Date: Sat, 18 Nov 2023 16:00:22 +0900 Subject: [PATCH] Update color --- lib/cli/cli.dart | 59 +++++++++++++++------------ lib/cli/commands/command_base.dart | 2 +- lib/cli/commands/command_manager.dart | 2 +- lib/oto/application.dart | 6 +-- 4 files changed, 37 insertions(+), 32 deletions(-) diff --git a/lib/cli/cli.dart b/lib/cli/cli.dart index ffc9e4a..c38f364 100644 --- a/lib/cli/cli.dart +++ b/lib/cli/cli.dart @@ -17,12 +17,12 @@ enum Color { cyan, lightGray, darkGray, - lightRed, - lightGreen, - lightYellow, - lightBlue, - lightMagenta, - lightCyan, + redStrong, + greenStrong, + yellowStrong, + blueStrong, + magentaStrong, + cyanStrong, white } @@ -51,12 +51,12 @@ class CLI { Color.cyan: "36", Color.lightGray: "37", Color.darkGray: "90", - Color.lightRed: "91", - Color.lightGreen: "92", - Color.lightYellow: "93", - Color.lightBlue: "94", - Color.lightMagenta: "95", - Color.lightCyan: "96", + Color.redStrong: "91", + Color.greenStrong: "92", + Color.yellowStrong: "93", + Color.blueStrong: "94", + Color.magentaStrong: "95", + Color.cyanStrong: "96", Color.white: "97" }; @@ -70,12 +70,12 @@ class CLI { Color.cyan: "46", Color.lightGray: "47", Color.darkGray: "100", - Color.lightRed: "101", - Color.lightGreen: "102", - Color.lightYellow: "103", - Color.lightBlue: "104", - Color.lightMagenta: "105", - Color.lightCyan: "106", + Color.redStrong: "101", + Color.greenStrong: "102", + Color.yellowStrong: "103", + Color.blueStrong: "104", + Color.magentaStrong: "105", + Color.cyanStrong: "106", Color.white: "107" }; @@ -112,28 +112,33 @@ class CLI { static get serviceName => CLI.current.config.serviceName; static get executableFileName => CLI.current.config.executableFileName; - static Future print(List printList, {Color? color}) async { - if (color != null) { + static Future print(List printList, + {Color? color, Color? background}) async { + if (color != null || background != null) { for (var i = 0; i < printList.length; ++i) { - printList[i] = CLI.style(printList[i], color: color); + printList[i] = + CLI.style(printList[i], color: color, background: background); } } await printer.printCLI(printList); return simpleFuture; } - static Future printBuffer(StringBuffer buffer, {Color? color}) async { - return await printString(buffer.toString(), color: color); + static Future printBuffer(StringBuffer buffer, + {Color? color, Color? background}) async { + return await printString(buffer.toString(), + color: color, background: background); } - static Future printString(String str, {Color? color}) async { + static Future printString(String str, + {Color? color, Color? background}) async { str = str.replaceAll('\r', ''); - return await print(str.split('\n'), color: color); + return await print(str.split('\n'), color: color, background: background); } - static Future println(String str, {Color? color}) async { + static Future println(String str, {Color? color, Color? background}) async { str = str.replaceAll('\n', '').replaceAll('\r', ''); - return await printString(str, color: color); + return await printString(str, color: color, background: background); } late CLIConfig config; diff --git a/lib/cli/commands/command_base.dart b/lib/cli/commands/command_base.dart index 2f96675..413d470 100644 --- a/lib/cli/commands/command_base.dart +++ b/lib/cli/commands/command_base.dart @@ -54,7 +54,7 @@ abstract class CommandBase { '', getDescription(), '', - 'Usage: ${CLI.style('$exeName $name $usage', color: Color.lightGreen)}$argumentDesc', + 'Usage: ${CLI.style('$exeName $name $usage', color: Color.greenStrong)}$argumentDesc', argumentTag, ]; diff --git a/lib/cli/commands/command_manager.dart b/lib/cli/commands/command_manager.dart index 17f2817..5511a7b 100644 --- a/lib/cli/commands/command_manager.dart +++ b/lib/cli/commands/command_manager.dart @@ -56,7 +56,7 @@ class CommandManager { '', 'A command-line $serviceName.', '', - 'Usage: ${CLI.style('$exeName <-h|[arguments]>', color: Color.lightGreen)}', + 'Usage: ${CLI.style('$exeName <-h|[arguments]>', color: Color.greenStrong)}', '', 'Available Command:', commandTag, diff --git a/lib/oto/application.dart b/lib/oto/application.dart index d279cb7..9406a06 100644 --- a/lib/oto/application.dart +++ b/lib/oto/application.dart @@ -83,9 +83,9 @@ class Application { break; } } on Exception catch (e, stacktace) { - await CLI.printString(e.toString(), color: Color.red); - await CLI.printString(stacktace.toString(), color: Color.yellow); - await printBuildStep('Build Failed', color: Color.lightRed); + await CLI.printString(e.toString(), color: Color.redStrong); + await CLI.printString(stacktace.toString(), color: Color.yellowStrong); + await printBuildStep('Build Failed', color: Color.redStrong); return; }