-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
53 lines (42 loc) · 1.11 KB
/
Program.cs
File metadata and controls
53 lines (42 loc) · 1.11 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
namespace prog1_ovnigar;
using System;
using System.Collections.Generic;
class Program
{
Menu mainMenu = new Menu("Main Menu");
static void Main(string[] args){
Debug.Clear();
Program p = new();
p.Run();
}
void Run(){
_Startup();
LoadMenuOptionsExercisesDirs();
mainMenu.AddOption("test");
mainMenu.Run();
}
static private void _Startup(){
if (!Directory.Exists("./exercises")) {Debug.Critical("./exercises/ don't exist");}
}
public void LoadMenuOptionsExercisesDirs(){
string[] dirs = Directory.GetDirectories("./exercises/");
for (int i = 0; i < dirs.Length; i++){
Debug.Log(dirs[i]);
if (_HasBasicFiles($"{dirs[i]}")){
mainMenu.AddOption(dirs[i]);
}
}
}
private bool _HasBasicFiles(string path){
string[] mainFile = Directory.GetFiles(path, "*-main.cs");
string[] dataFile = Directory.GetFiles(path, "*-data.json");
// temp
// TODO: fix better error handling
if (mainFile.Length == 0 || dataFile.Length == 0){
Debug.Warn("Missing files in: " + path);
return false;
}
Debug.Log($"main file: {mainFile[0]} \nData file: {dataFile[0]}");
return true;
}
}