forked from Nadelio/Apollo-Language-Reimagined
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
70 lines (59 loc) · 2.09 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
64
65
66
67
68
69
70
using CommandLine;
public class Entry
{
public class Options
{
[Option('v', "verbose", Required = false, HelpText = "Enable verbose output.")]
public bool Verbose { get; set; }
[Option('i', "input", Required = true, HelpText = "Input file path.")]
public string? InputFilePath { get; set; }
[Option('o', "output", Required = false, HelpText = "Output file path.")]
public string? OutputFilePath { get; set; }
}
public static void Main(string[] args)
{
CommandLine.Parser.Default
.ParseArguments<Options>(args)
.WithParsed(Run)
.WithNotParsed(HandleParseError);
}
private static void Run(Options opts)
{
if (opts.Verbose)
{
Console.WriteLine("Verbose mode enabled");
}
if (!File.Exists(opts.InputFilePath) || !opts.InputFilePath!.EndsWith(".sun"))
{
Console.WriteLine("Invalid or non-existent input file. Please provide a valid .sun file.");
return;
}
string outputFilePath = opts.OutputFilePath ?? Path.ChangeExtension(opts.InputFilePath, ".out");
if (opts.Verbose)
{
Console.WriteLine($"Processing file: {opts.InputFilePath}");
Console.WriteLine($"Output will be saved to: {outputFilePath}");
}
string content = File.ReadAllText(opts.InputFilePath);
string transpiledContent = content; //SimulateProcessing(content);
File.WriteAllText(outputFilePath, transpiledContent);
if (opts.Verbose)
{
Console.WriteLine("File processed successfully.");
}
}
private static void HandleParseError(IEnumerable<Error> errs)
{
foreach (var error in errs)
{
if (error is MissingRequiredOptionError missingOptionError)
{
Console.WriteLine($"Missing required option: {missingOptionError.NameInfo.NameText}");
}
else
{
Console.WriteLine("Error parsing arguments.");
}
}
}
}