mirror of
https://github.com/2dust/v2rayN.git
synced 2025-05-11 18:58:20 +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]
|
||||
private static void Main(string[] args)
|
||||
{
|
||||
if (args.Length == 0)
|
||||
try
|
||||
{
|
||||
Console.WriteLine(Resx.Resource.Guidelines);
|
||||
Thread.Sleep(5000);
|
||||
return;
|
||||
}
|
||||
// If no arguments are provided, display usage guidelines and exit
|
||||
if (args.Length == 0)
|
||||
{
|
||||
ShowHelp();
|
||||
return;
|
||||
}
|
||||
|
||||
var argData = Uri.UnescapeDataString(string.Join(" ", args));
|
||||
if (argData.Equals("rebootas"))
|
||||
// Log all arguments for debugging purposes
|
||||
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);
|
||||
Utils.StartV2RayN();
|
||||
return;
|
||||
// Global exception handling
|
||||
Console.WriteLine($"An error occurred: {ex.Message}");
|
||||
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