diff --git a/CodeLegacy/Cli.cs b/CodeLegacy/Cli.cs
index 762ac78..5ec874f 100644
--- a/CodeLegacy/Cli.cs
+++ b/CodeLegacy/Cli.cs
@@ -15,6 +15,8 @@ namespace Flowframes
public class Cli
{
public static bool Debug = false;
+ public static bool ShowHelp = false;
+ public static bool CanStart = false;
public static bool DisablePython = true;
public static bool ShowMdlDownloader = false;
public static bool CloseMdlDownloaderWhenDone = false;
@@ -37,12 +39,17 @@ namespace Flowframes
[DllImport("kernel32.dll", SetLastError = true)]
private static extern int FreeConsole();
- public static void HandleCli()
+ /// Parses command line args. Returns if the program should continue (true) or exit (false).
+ public static bool HandleCli()
{
string GetEnums() => string.Join(", ", Enum.GetNames(typeof(T)));
var optsSet = new OptionSet
{
+ {
+ "h|help", "Show CLI help",
+ v => ShowHelp = v != null
+ },
{
"d|debug", "Enable debug/developer features and experimental or deprecated options",
v => Debug = v != null
@@ -125,26 +132,34 @@ namespace Flowframes
},
};
- var opts = new ArgParseExtensions.Options() { OptionsSet = optsSet, BasicUsage = " ", AddHelpArg = true };
+ var opts = new ArgParseExtensions.Options() { OptionsSet = optsSet, BasicUsage = " ", AddHelpArg = false };
try
{
- if (!opts.TryParseOptions(Environment.GetCommandLineArgs()))
- return;
+ var args = Environment.GetCommandLineArgs();
- // if (!ShowConsole)
- // FreeConsole();
+ if (!opts.TryParseOptions(args))
+ return false;
+ bool noArgs = args.Select(a => a.TrimStart('-').Lower().Trim('"')).Where(a => !a.EndsWith(".exe") && a != "h" && a != "help").Count() < 1; // No args passed (apart from program exe path and/or help flag)
+
+ if (Program.CmdMode && (noArgs || ShowHelp))
+ {
+ opts.PrintHelp();
+ }
+
Python.DisablePython = DisablePython;
Config.NoWrite = DontSaveConfig;
ValidFiles = ValidFiles.Where(f => File.Exists(f) && Path.GetExtension(f).Lower() != ".exe").Distinct().ToList();
AutoRun = AutoRun && ValidFiles.Any(); // Only AutoRun if valid files are provided
DontSaveConfig = DontSaveConfig || AutoRun; // Never save config in AutoRun mode
+ return CanStart;
}
catch (OptionException e)
{
Logger.Log($"Error parsing CLI options: {e.Message}", true);
+ return false;
}
}
}
diff --git a/CodeLegacy/Main/Interpolate.cs b/CodeLegacy/Main/Interpolate.cs
index df80ad3..3472602 100644
--- a/CodeLegacy/Main/Interpolate.cs
+++ b/CodeLegacy/Main/Interpolate.cs
@@ -38,7 +38,6 @@ namespace Flowframes
if (!Utils.CheckPathValid(currentSettings.inPath)) return; // Check if input path/file is valid
if (!Utils.CheckAiAvailable(currentSettings.ai, currentSettings.model)) return; // Check if selected AI pkg is installed
if (!AutoEncodeResume.resumeNextRun && !Utils.CheckDeleteOldTempFolder()) return; // Try to delete temp folder if an old one exists
- if (!(await Utils.CheckEncoderValid())) return; // Check encoder compat
currentSettings.stepByStep = false;
Program.mainForm.Invoke(() => Program.mainForm.SetStatus("Starting..."));
sw.Restart();
diff --git a/CodeLegacy/Program.cs b/CodeLegacy/Program.cs
index 8523d3a..5c58595 100644
--- a/CodeLegacy/Program.cs
+++ b/CodeLegacy/Program.cs
@@ -40,9 +40,14 @@ namespace Flowframes
Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
+ CmdMode = Paths.GetExe().EndsWith("Cmd.exe");
Cli.HandleCli();
Debug = Cli.Debug || System.Diagnostics.Debugger.IsAttached;
- CmdMode = Paths.GetExe().EndsWith("Cmd.exe");
+
+ if(CmdMode && !Cli.CanStart)
+ {
+ Environment.Exit(0);
+ }
// Show splash screen
Application.EnableVisualStyles();