-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
39 lines (35 loc) · 1.33 KB
/
Copy pathProgram.cs
File metadata and controls
39 lines (35 loc) · 1.33 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
namespace YuchikiML {
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System;
using CommandLine;
class Program {
static void Main(string[] args) {
// TODO: Add argParser;
Logger.Criteria = Logger.ErrorLevel.Error;
Parser.Default.ParseArguments<CommandLineOptions>(args).WithParsed<CommandLineOptions>(
opt => {
ValidateOpt(opt);
Logger.Criteria = opt.ErrorLevel;
if (opt.Verbose) Logger.Criteria = Logger.ErrorLevel.Trace;
if (opt.IsTestMode) {
TestSuits.Test();
return;
}
Executor.Execute(new SourceFile(opt.FileName));
}
);
}
static void ValidateOpt(CommandLineOptions opt) {
if (opt.FileName != null && opt.IsTestMode) {
Console.Error.WriteLine(" File name cannot be designated in test mode.");
Environment.Exit(1);
} else if (opt.FileName == null && !opt.IsTestMode) {
Console.Error.WriteLine(" File not designated.");
Console.Error.WriteLine("--help to see help.");
Environment.Exit(1);
}
}
}
}