-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
42 lines (36 loc) · 1.02 KB
/
Program.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
using System.Globalization;
using System.Text;
using System.Text.Json;
using TextCopy;
if (args.Length != 1)
{
Console.WriteLine("Need 1 argument to the folder contaning config.json from fontello");
return;
}
//it can be full file path or just the folder
var path = args[0];
if (!File.Exists(path))
{
path = Path.Combine(path, "config.json");
}
if (!File.Exists(path))
{
Console.WriteLine("Path not found");
return;
}
var json = File.ReadAllText(path);
var config = JsonSerializer.Deserialize<FontelloConfig>(json);
var sb = new StringBuilder();
sb.AppendLine(@"public static class Icons
{");
foreach (var item in config.glyphs)
{
TextInfo info = CultureInfo.CurrentCulture.TextInfo;
var name = item.css.Replace("-", "_").Replace(" ", "_");
name = info.ToTitleCase(name);
sb.AppendLine($"\tpublic const string {name} = \"\\u{item.code.ToString("X")}\";");
}
sb.AppendLine("}");
var content = sb.ToString();
Console.WriteLine(content);
ClipboardService.SetText(content);