|
12 | 12 | */
|
13 | 13 | package org.web3j.console.openapi.utils
|
14 | 14 |
|
15 |
| -import com.diogonunes.jcdp.color.ColoredPrinter |
16 |
| -import com.diogonunes.jcdp.color.api.Ansi |
17 | 15 | import org.web3j.console.project.utils.InstructionsPrinter
|
18 | 16 |
|
| 17 | +import org.fusesource.jansi.Ansi |
| 18 | + |
19 | 19 | object PrettyPrinter {
|
20 |
| - private val cp = ColoredPrinter.Builder(0, false) |
21 |
| - .foreground(Ansi.FColor.WHITE) |
22 |
| - .background(Ansi.BColor.GREEN) |
23 |
| - .attribute(Ansi.Attribute.BOLD) |
24 |
| - .build() |
25 |
| - private val cpf = ColoredPrinter.Builder(0, false) |
26 |
| - .foreground(Ansi.FColor.RED) |
27 |
| - .background(Ansi.BColor.YELLOW) |
28 |
| - .attribute(Ansi.Attribute.BOLD) |
29 |
| - .build() |
30 |
| - private val instructionPrinter = ColoredPrinter.Builder(0, false).foreground(Ansi.FColor.CYAN).build() |
31 |
| - private val commandPrinter = ColoredPrinter.Builder(0, false).foreground(Ansi.FColor.GREEN).build() |
32 | 20 |
|
33 | 21 | fun onOpenApiProjectSuccess() {
|
34 | 22 | InstructionsPrinter.initContextPrinter(null)
|
35 |
| - InstructionsPrinter.getContextPrinterInstance().contextPrinter.printInstructionsOnSuccessOpenApi( |
36 |
| - instructionPrinter, commandPrinter |
37 |
| - ) |
| 23 | + InstructionsPrinter.getContextPrinterInstance().contextPrinter.printInstructionsOnSuccessOpenApi() |
38 | 24 | }
|
39 | 25 |
|
40 | 26 | fun onJarSuccess() {
|
41 |
| - print(System.lineSeparator()) |
42 |
| - cp.println("JAR generated Successfully") |
43 |
| - print(System.lineSeparator()) |
| 27 | + println(System.lineSeparator()) |
| 28 | + println(Ansi.ansi().fgGreen().bold().a("JAR generated Successfully").reset()) |
| 29 | + println(System.lineSeparator()) |
44 | 30 |
|
45 |
| - instructionPrinter.println( |
46 |
| - "Commands", Ansi.Attribute.LIGHT, Ansi.FColor.YELLOW, Ansi.BColor.BLACK |
47 |
| - ) |
48 |
| - instructionPrinter.print(String.format("%-45s", "java -jar <jar_name> <args>")) |
49 |
| - commandPrinter.println("Run your Jar") |
50 |
| - instructionPrinter.print(String.format("%-45s", "java -jar <jar_name> --help")) |
51 |
| - commandPrinter.println("See the available options") |
| 31 | + println(Ansi.ansi().fgCyan().a("Commands").reset()) |
| 32 | + println(String.format("%-45s", "java -jar <jar_name> <args>") + Ansi.ansi().fgGreen().a(" Run your Jar").reset()) |
| 33 | + println(String.format("%-45s", "java -jar <jar_name> --help") + Ansi.ansi().fgGreen().a(" See the available options").reset()) |
52 | 34 | }
|
53 | 35 |
|
54 | 36 | fun onSuccess() {
|
55 |
| - print(System.lineSeparator()) |
56 |
| - cp.println("Project generated Successfully") |
57 |
| - print(System.lineSeparator()) |
| 37 | + println(System.lineSeparator()) |
| 38 | + println(Ansi.ansi().fgGreen().bold().a("Project generated Successfully").reset()) |
| 39 | + println(System.lineSeparator()) |
58 | 40 | }
|
59 | 41 |
|
60 | 42 | fun onFailed() {
|
61 |
| - print(System.lineSeparator()) |
62 |
| - cpf.println("Project generation Failed. Check log file for more information.") |
63 |
| - print(System.lineSeparator()) |
| 43 | + println(System.lineSeparator()) |
| 44 | + println(Ansi.ansi().fgRed().bold().a("Project generation Failed. Check log file for more information.").reset()) |
| 45 | + println(System.lineSeparator()) |
64 | 46 | }
|
65 | 47 |
|
66 | 48 | fun onWrongPath() {
|
67 |
| - print(System.lineSeparator()) |
68 |
| - cpf.println("No Solidity smart contracts found! Please enter a correct path containing Solidity code.") |
69 |
| - print(System.lineSeparator()) |
| 49 | + println(System.lineSeparator()) |
| 50 | + println(Ansi.ansi().fgRed().bold().a("No Solidity smart contracts found! Please enter a correct path containing Solidity code.").reset()) |
| 51 | + println(System.lineSeparator()) |
70 | 52 | }
|
71 | 53 | }
|
0 commit comments