2026-10-08 11:50:57 +02:00
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Windows.Forms;
|
|
|
|
|
|
|
|
|
|
if (args.Length == 0)
|
|
|
|
|
{
|
2026-10-08 12:23:32 +02:00
|
|
|
// WebView2 richiede un thread STA, che i top-level statements non danno
|
|
|
|
|
var ui = new Thread(() =>
|
|
|
|
|
{
|
|
|
|
|
ApplicationConfiguration.Initialize();
|
2026-10-08 13:29:53 +02:00
|
|
|
Application.SetColorMode(SystemColorMode.System);
|
2026-10-08 12:23:32 +02:00
|
|
|
Application.Run(new Gui());
|
|
|
|
|
});
|
|
|
|
|
ui.SetApartmentState(ApartmentState.STA);
|
|
|
|
|
ui.Start();
|
|
|
|
|
ui.Join();
|
2026-10-08 11:50:57 +02:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var psi = NewClaude(string.Join(' ', args));
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
using var p = Process.Start(psi)!; // stdout/stderr ereditati: streaming in tempo reale
|
|
|
|
|
p.StandardInput.Close();
|
|
|
|
|
p.WaitForExit();
|
|
|
|
|
return p.ExitCode;
|
|
|
|
|
}
|
|
|
|
|
catch (System.ComponentModel.Win32Exception)
|
|
|
|
|
{
|
|
|
|
|
Console.Error.WriteLine("'claude' non trovato nel PATH.");
|
|
|
|
|
return 127;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static ProcessStartInfo NewClaude(string prompt)
|
|
|
|
|
{
|
|
|
|
|
var psi = new ProcessStartInfo("claude")
|
|
|
|
|
{
|
|
|
|
|
WorkingDirectory = AppContext.BaseDirectory,
|
|
|
|
|
UseShellExecute = false,
|
|
|
|
|
RedirectStandardInput = true, // evita l'attesa di stdin di claude
|
|
|
|
|
};
|
|
|
|
|
psi.ArgumentList.Add("-p");
|
|
|
|
|
psi.ArgumentList.Add(prompt);
|
|
|
|
|
return psi;
|
|
|
|
|
}
|