-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram.cs
63 lines (49 loc) · 1.83 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// Top-level statement
// get args
if (args.Length > 0){
string pathString = args[0] ;
//checked file path
bool exists = pathString.IndexOfAny(Path.GetInvalidPathChars()) == -1;
if (exists) {
Project p = new Project(pathString,0);
p.Search();
Console.WriteLine("");
Console.WriteLine(p.Filename);
Treeview(p.Dependencies,"") ;
//export graph
Globals.FLAT = new Dictionary<String, Project>() ;
string text = p.Output();
string title = p.Filename ;
string outputfile = title + ".html" ;
// Write output from html template
var template = File.ReadAllText("template.html");
var html = template
.Replace("{{output}}", text)
.Replace("{{title}}", title);
File.WriteAllText(outputfile, html);
// done
Console.WriteLine("");
Console.WriteLine("output graph: " + outputfile);
Console.WriteLine("run cmd: start " + outputfile );
}
} else {
Console.WriteLine($"Project path is missing");
}
static void Treeview(List<Project> nodes, string level) {
string treeLevel = "├── " ;
string treeEnd = "└── " ;
string treeOpen = "│ " ;
string treeClosed = " " ;
if (nodes != null){
int position = 0 ;
int last = nodes.Count - 1 ;
foreach(Project node in nodes) {
bool end = position == last ;
string treeSeparator = end ? treeEnd : treeLevel ;
string LevelSeparator = end ? treeClosed : treeOpen ;
Console.WriteLine( level + treeSeparator + node.Filename);
Treeview(node.Dependencies, level + LevelSeparator);
position ++ ;
}
}
}