mirror of
https://github.com/2dust/v2rayN.git
synced 2025-05-14 12:18:06 +00:00
Improved AmazTool
This commit is contained in:
parent
3f19958c75
commit
ea42246d1b
1 changed files with 73 additions and 11 deletions
|
@ -5,21 +5,83 @@ internal static class Program
|
||||||
[STAThread]
|
[STAThread]
|
||||||
private static void Main(string[] args)
|
private static void Main(string[] args)
|
||||||
{
|
{
|
||||||
if (args.Length == 0)
|
try
|
||||||
{
|
{
|
||||||
Console.WriteLine(Resx.Resource.Guidelines);
|
// If no arguments are provided, display usage guidelines and exit
|
||||||
Thread.Sleep(5000);
|
if (args.Length == 0)
|
||||||
return;
|
{
|
||||||
}
|
ShowHelp();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var argData = Uri.UnescapeDataString(string.Join(" ", args));
|
// Log all arguments for debugging purposes
|
||||||
if (argData.Equals("rebootas"))
|
foreach (var arg in args)
|
||||||
|
{
|
||||||
|
Console.WriteLine(arg);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Parse command based on first argument
|
||||||
|
switch (args[0].ToLowerInvariant())
|
||||||
|
{
|
||||||
|
case "rebootas":
|
||||||
|
// Handle application restart
|
||||||
|
HandleRebootAsync();
|
||||||
|
break;
|
||||||
|
|
||||||
|
case "help":
|
||||||
|
case "--help":
|
||||||
|
case "-h":
|
||||||
|
case "/?":
|
||||||
|
// Display help information
|
||||||
|
ShowHelp();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
// Default behavior: handle as upgrade data
|
||||||
|
// Maintain backward compatibility with existing usage pattern
|
||||||
|
var argData = Uri.UnescapeDataString(string.Join(" ", args));
|
||||||
|
HandleUpgrade(argData);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Thread.Sleep(1000);
|
// Global exception handling
|
||||||
Utils.StartV2RayN();
|
Console.WriteLine($"An error occurred: {ex.Message}");
|
||||||
return;
|
Console.WriteLine("Press any key to exit...");
|
||||||
|
Console.ReadKey();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
UpgradeApp.Upgrade(argData);
|
/// <summary>
|
||||||
|
/// Display help information and usage guidelines
|
||||||
|
/// </summary>
|
||||||
|
private static void ShowHelp()
|
||||||
|
{
|
||||||
|
Console.WriteLine(Resx.Resource.Guidelines);
|
||||||
|
Console.WriteLine("Available commands:");
|
||||||
|
Console.WriteLine(" rebootas - Restart the application");
|
||||||
|
Console.WriteLine(" help - Display this help information");
|
||||||
|
Thread.Sleep(5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handle application restart
|
||||||
|
/// </summary>
|
||||||
|
private static void HandleRebootAsync()
|
||||||
|
{
|
||||||
|
Console.WriteLine("Restarting application...");
|
||||||
|
Thread.Sleep(1000);
|
||||||
|
Utils.StartV2RayN();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Handle application upgrade with the provided data
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="upgradeData">Data for the upgrade process</param>
|
||||||
|
private static void HandleUpgrade(string upgradeData)
|
||||||
|
{
|
||||||
|
Console.WriteLine("Upgrading application...");
|
||||||
|
UpgradeApp.Upgrade(upgradeData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue