mirror of
https://github.com/imrayya/SRTto3Dsubtitles.git
synced 2026-09-21 10:17:27 +02:00
fix: wire up GUI browse buttons, make text boxes editable, pause CLI on error, register codepage provider
GUI: - Attach Click event handlers to browse input/output buttons (were defined but never wired up) - Remove ReadOnly=true from input/output text boxes so users can type or copy paths CLI: - Make Cli.Run return bool to signal errors - Only pause with Console.ReadLine() when an error occurs (not on success) - Fix default case to return true Core: - Add System.Text.Encoding.CodePages package for CP1252 SRT file support - Call Encoding.RegisterProvider(CodePagesEncodingProvider.Instance) before reading files
This commit is contained in:
@@ -4,19 +4,19 @@ namespace ConvertSRTto3DASS;
|
||||
|
||||
internal static class Cli
|
||||
{
|
||||
public static void Run(string[] args)
|
||||
public static bool Run(string[] args)
|
||||
{
|
||||
if (args.Length == 0 || args[0] is "--help" or "-h" or "/?")
|
||||
{
|
||||
PrintUsage();
|
||||
return;
|
||||
return false;
|
||||
}
|
||||
|
||||
var inputPath = args[0];
|
||||
if (!File.Exists(inputPath))
|
||||
{
|
||||
Console.Error.WriteLine($"Input file not found: {inputPath}");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Parse options
|
||||
@@ -80,7 +80,7 @@ internal static class Cli
|
||||
break;
|
||||
default:
|
||||
Console.Error.WriteLine($"Unknown argument: {args[i]}");
|
||||
return;
|
||||
return true;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
@@ -106,11 +106,13 @@ internal static class Cli
|
||||
var result = SrtConverter.Convert(options);
|
||||
Console.WriteLine($"Parsed: {result.SubtitleCount} subtitle blocks");
|
||||
Console.WriteLine("Conversion complete.");
|
||||
return false;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine($"ERROR: {ex.Message}");
|
||||
Console.Error.WriteLine(ex.ToString());
|
||||
return true;
|
||||
}
|
||||
|
||||
string GetNextArg(int index) => index + 1 < args.Length ? args[index + 1] : throw new ArgumentException($"Missing value for {args[index]}");
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'">
|
||||
<Optimize>true</Optimize>
|
||||
<PublishSingleFile>true</PublishSingleFile>
|
||||
<PublishReadyToRun>false</PublishReadyToRun>
|
||||
<StripSymbols>true</StripSymbols>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
||||
@@ -2,5 +2,10 @@ namespace ConvertSRTto3DASS;
|
||||
|
||||
internal static class Program
|
||||
{
|
||||
static void Main(string[] args) => Cli.Run(args);
|
||||
static void Main(string[] args)
|
||||
{
|
||||
var hadError = Cli.Run(args);
|
||||
if (hadError)
|
||||
Console.ReadLine();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user