-
Notifications
You must be signed in to change notification settings - Fork 397
/
Copy pathSpectreConsoleOutput.cs
111 lines (97 loc) · 3.96 KB
/
SpectreConsoleOutput.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
// Copyright (c) 2024
// Author : Bruno Capuano
// Change Log :
//
// The MIT License (MIT)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#pragma warning disable SKEXP0001, SKEXP0003, SKEXP0010, SKEXP0011, SKEXP0050, SKEXP0052
using Spectre.Console;
namespace LabsPhi304;
public static class SpectreConsoleOutput
{
public static void DisplayTitle(string title = ".NET - Phi-3 Vision Sample")
{
AnsiConsole.Write(new FigletText(title).Centered().Color(Color.Purple));
}
public static void DisplayTitleH2(string subtitle)
{
AnsiConsole.MarkupLine($"[bold][blue]=== {subtitle} ===[/][/]");
AnsiConsole.MarkupLine($"");
}
public static void DisplayTitleH3(string subtitle)
{
AnsiConsole.MarkupLine($"[bold]>> {subtitle}[/]");
AnsiConsole.MarkupLine($"");
}
public static void DisplayQuestion(string question)
{
AnsiConsole.MarkupLine($"[bold][blue]>>Q: {question}[/][/]");
AnsiConsole.MarkupLine($"");
}
public static void DisplayAnswerStart(string answerPrefix)
{
AnsiConsole.Markup($"[bold][blue]>> {answerPrefix}:[/][/]");
}
public static void DisplayFilePath(string prefix, string filePath)
{
var path = new TextPath(filePath);
AnsiConsole.Markup($"[bold][blue]>> {prefix}: [/][/]");
AnsiConsole.Write(path);
AnsiConsole.MarkupLine($"");
}
public static void DisplaySubtitle(string prefix, string content)
{
AnsiConsole.Markup($"[bold][blue]>> {prefix}: [/][/]");
AnsiConsole.WriteLine(content);
AnsiConsole.MarkupLine($"");
}
public static int AskForNumber(string question)
{
var number = AnsiConsole.Ask<int>(@$"[green]{question}[/]");
return number;
}
public static string AskForString(string question)
{
var response = AnsiConsole.Ask<string>(@$"[green]{question}[/]");
return response;
}
public static List<string> SelectScenarios()
{
// Ask for the user's favorite fruits
var scenarios = AnsiConsole.Prompt(
new MultiSelectionPrompt<string>()
.Title("Select the [green]Phi 3 Vision scenarios[/] to run?")
.PageSize(10)
.Required(true)
.MoreChoicesText("[grey](Move up and down to reveal more scenarios)[/]")
.InstructionsText(
"[grey](Press [blue]<space>[/] to toggle a scenario, " +
"[green]<enter>[/] to accept)[/]")
.AddChoiceGroup("Select an image to be analuyzed", new[]
{"foggyday.png","foggydaysmall.png","petsmusic.png","ultrarunningmug.png",
})
.AddChoices( new[] {
"Type the image path to be analyzed",
"Type a question"
})
);
return scenarios;
}
}