forked from scriptcs/scriptcs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVersionWriter.cs
More file actions
54 lines (47 loc) · 1.75 KB
/
VersionWriter.cs
File metadata and controls
54 lines (47 loc) · 1.75 KB
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
using System;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
namespace ScriptCs
{
public static class VersionWriter
{
private static readonly string version =
FileVersionInfo.GetVersionInfo(typeof(VersionWriter).Assembly.Location).ProductVersion;
private static readonly Regex colorRegex = new Regex(
@"\+(?<color>\w*)(?<ascii>(.*(?=\+))|.*)", RegexOptions.Compiled | RegexOptions.Singleline);
public static void Write()
{
var lines = new[]
{
@"+cyan _ _",
@"+cyan ___ ___ _ __(_)_ __ | |__+darkMagenta ___ ___",
@"+cyan/ __|/ __| '__| | '_ \| __/+darkMagenta/ __/ __|",
@"+cyan\__ \ (__| | | | |_) | |_+darkMagenta| (__\__ \",
@"+cyan|___/\___|_| |_| .__/ \__\+darkMagenta\___|___/",
string.Format(@"+cyan |_|+white Version: {0}", version)
};
foreach (var lineMatches in lines.Select(line => colorRegex.Matches(line)))
{
foreach (Match match in lineMatches)
{
ConsoleColor color;
if (Enum.TryParse(match.Groups["color"].Value, true, out color))
{
Console.ForegroundColor = color;
}
try
{
Console.Write(match.Groups["ascii"].Value);
}
finally
{
Console.ResetColor();
}
}
Console.WriteLine();
}
Console.WriteLine();
}
}
}