当前位置:网站首页>A cool "ghost" console tool
A cool "ghost" console tool
2022-07-07 05:20:00 【InfoQ】
brief introduction
A console plug-in mentioned yesterday to be introduced , Today it comes !
- Full name :Spectre.Console
- Translated names ( unofficial ): Ghost console ( Hereinafter referred to as ghost )
Why write this ! Hey , Because of course , There is no sorting , It's really a busy job ,
Forced migrant workers
/(ㄒoㄒ)/~~
And these are commonly used things at hand , As the anchor with goods said , I used it myself , It's really easy to use , And cool enough , Dare to recommend it to you .
In fact, there are many beautiful console tools , such as ColorfulConsole,ConsoleTables etc. , Even the built-in console style is enough in most scenarios , What's special about this tool ?
features
- New enough: The tools mentioned above , Or some did not mention , But tools with a large number of downloads , The update frequency is very slow , I want to be very angry ColorfulConsole, The last update has stopped 2020 year , So despite its powerful functions , But the vitality is not good . Ghosts are different , Look at the official release records , He is now in rapid iterative update , Abreast of the times 0.44.x edition , It has been updated 13 It's a small version , Yes, of course , Frequent updates are not necessarily a good thing , It also reflects many problems , Mending , But that's exactly what happened , It proves that it is energetic , It's worth affirming !
- Cool:I don't want to explain that , Look at the picture
- Strong enough :It can also be seen from the above figure , Ghost offers a variety of console printing styles , In addition to the processing of text style , And support , form , Trees , Progress bar , Even emoji expression ( The system configuration needs to be modified )
Three points above , It's enough for me to choose it . If there are any shortcomings , There are no Chinese documents at present , Of course , I have Jinshan drug bully , incorrect , ICIBA ! therefore , It's nothing !
Use
Actually , About use , Official documents give enough cases , Here I will simply list a few use cases .
typeface
Use ghosts to print fonts of various styles , A bit like an editor Html file , Just go through markup(Line) Method , Write special keywords and placeholders in the text to be output .
For example, you need to print colored words
AnsiConsole.MarkupLine($"[Yellow] I am the first 2 Middleware , I come from the entry file , I'm coming -{DateTime.Now}[/]"); Make it bold
AnsiConsole.MarkupLine("[bold]World[/]"); Be bold and have color
AnsiConsole.MarkupLine("[bold Yellow]World[/]"); Basic keywords and html The style is very similar , And underline , Escape, etc , I won't list them all .
form
Ghost's support for forms , In addition to supporting static tables , It also supports dynamic tables
- Static tables
Just recently, I made a tool to monitor table changes , Constructed a table , Take it as an example
var table = new Table().Centered();
table.AddColumn(" Authorized person ID");
table.AddColumn(" Authorized events ID");
table.AddColumn(" Authorized person ");
while (sdr.Read())
{
string column1 = Convert.ToString(sdr["UserID"]);
string column2 = Convert.ToString(sdr["TypeID"]);
string column3 = Convert.ToString(sdr["UserNam"]);
table.AddRow(column1, column2, column3);
}
AnsiConsole.Write(table); In fact, it is to construct tables , Define column headers , Then print the contents of each line in sequence .
Of course, I'm just printing here , Ghost also supports adjusting the structure of the table , For example, the display is centered , Set borders , Set cell width, etc .
The code is also very simple
// Set width
table.Width(50);
// Set offset
table.Columns[0].PadLeft(3);
// Set borders , Draw a circle
table.Border(TableBorder.Square); Official documents
There are more cases in , You can go and have a look
- Dynamic tables
I haven't arrived yet , But official documents give several examples , It's very cool , Recording Gif to glance at .

FIGlet Text
I don't know how to translate this Chinese name , The effect is to make the text effect of dotted lines , Just like this.

It's very easy to use
AnsiConsole.Write(
new FigletText("Tony's Box")
.Centered()
.Color(Color.Blue)
);choice
Like the screenshot above , The selection operation can be realized , As in the Bios The parameters set in the interface are the same
var cmd = AnsiConsole.Prompt(
new SelectionPrompt<string>()
.Title(" The following are the operations temporarily supported by the toolkit ?")
.PageSize(10)
.MoreChoicesText("[grey]( Please select the operation to be performed )[/]")
.AddChoices(new[] {
"1. monitor 【User_ProgramTypeLink】 Permissions on the table ","2. Clear the log data half a year ago ", "3. Delete the specified index data "
})); Okay , That's basically it . Good night, !
边栏推荐
猜你喜欢
随机推荐
What changes will PMP certification bring?
app内嵌h5---iphone软键盘遮挡输入文字
How can project managers counter attack with NPDP certificates? Look here
利用OPNET进行网络单播(一服务器多客户端)仿真的设计、配置及注意点
Window scheduled tasks
[question] Compilation Principle
Autowired注解用于List时的现象解析
最全常用高数公式
漏电继电器JELR-250FG
高数中值定理总结
精彩速递|腾讯云数据库6月刊
LabVIEW在打开一个新的引用,提示内存已满
Redis如何实现多可用区?
局部变量的数组初始化问题
Addressable 预下载
The execution order of return in JS' try catch finally
腾讯云数据库公有云市场稳居TOP 2!
Analysis -- MySQL statement execution process & MySQL architecture
记录一次压测经验总结
How can professional people find background music materials when doing we media video clips?









