Update color
This commit is contained in:
parent
49559dfeb8
commit
6529b7095e
4 changed files with 37 additions and 32 deletions
|
|
@ -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<String> printList, {Color? color}) async {
|
||||
if (color != null) {
|
||||
static Future print(List<String> 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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
];
|
||||
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class CommandManager {
|
|||
'',
|
||||
'A command-line $serviceName.',
|
||||
'',
|
||||
'Usage: ${CLI.style('$exeName <command> <-h|[arguments]>', color: Color.lightGreen)}',
|
||||
'Usage: ${CLI.style('$exeName <command> <-h|[arguments]>', color: Color.greenStrong)}',
|
||||
'',
|
||||
'Available Command:',
|
||||
commandTag,
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue