Caa/src/Program.bf

72 lines
No EOL
1.6 KiB
Beef

namespace Caa;
using System;
class Program
{
public static int Main(String[] args)
{
Console.WriteLine("""
Caa - Generate a Beef binding for c headers
Version 1.0.0
-------------------------------------------
First you need to input your arguments like the ones you would pass into clang
(This includes the path to the input header)
First give me the amount of arguments you want to have.
""");
String paramCount = scope .();
if(Console.ReadLine(paramCount) case .Err)
{
PrintError("ERROR: Could not read your input");
return -1;
}
var count = int.Parse(paramCount);
if(count case .Err)
{
PrintError("ERROR: Could not parse the input number into a int");
return -1;
}
String[] arguments = new String[count.Value];
defer delete arguments;
for(var i < arguments.Count)
{
Console.WriteLine(scope $"Please input your argument at offset {i}");
String arg = scope:: .();
if(Console.ReadLine(arg) case .Err)
{
PrintError("ERROR: Could not read your argument");
return -1;
}
arguments[i] = arg;
}
Binding.Bind(ref arguments);
Console.WriteLine("Finished analyzing the file now please input your output directory/file");
String output = scope .();
if(Console.ReadLine(output) case .Err)
{
PrintError("ERROR: Could not read the output directory");
return -1;
}
if(Binding.Generate(output) case .Err)
{
PrintError("ERROR: Could not properly generate or output the binding");
return -1;
}
return 0;
}
private static void PrintError(StringView pText)
{
Console.ForegroundColor = .Red;
Console.WriteLine(pText);
Console.ForegroundColor = .White;
}
}