Correct the type for --waitForExit in Start (UpToolCLI)
This commit is contained in:
parent
14b2643cbf
commit
ddbfb39e87
|
@ -13,12 +13,14 @@ namespace Installer
|
||||||
{
|
{
|
||||||
public static class Program
|
public static class Program
|
||||||
{
|
{
|
||||||
|
public static bool Basic;
|
||||||
public static int Main(string[] args)
|
public static int Main(string[] args)
|
||||||
{
|
{
|
||||||
Thread.Sleep(2000);
|
Thread.Sleep(2000);
|
||||||
MutexLock.Lock();
|
MutexLock.Lock();
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
Basic = args.Length > 0 && args[0].ToLower() == "--basic";
|
||||||
ExternalFunctionalityManager.Init(new UtLibFunctions());
|
ExternalFunctionalityManager.Init(new UtLibFunctions());
|
||||||
RootCommand rootCommand = new RootCommand();
|
RootCommand rootCommand = new RootCommand();
|
||||||
Command install = new Command("install", "Install UpTool")
|
Command install = new Command("install", "Install UpTool")
|
||||||
|
|
|
@ -5,6 +5,7 @@ using System.Threading;
|
||||||
using SixLabors.ImageSharp;
|
using SixLabors.ImageSharp;
|
||||||
using SixLabors.ImageSharp.Processing;
|
using SixLabors.ImageSharp.Processing;
|
||||||
using UpToolLib.DataStructures;
|
using UpToolLib.DataStructures;
|
||||||
|
using static Installer.Program;
|
||||||
|
|
||||||
namespace Installer
|
namespace Installer
|
||||||
{
|
{
|
||||||
|
@ -25,9 +26,12 @@ namespace Installer
|
||||||
};
|
};
|
||||||
client.DownloadProgressChanged += (sender, e) =>
|
client.DownloadProgressChanged += (sender, e) =>
|
||||||
{
|
{
|
||||||
Console.Write(
|
if (!Basic)
|
||||||
$"{new string('=', e.ProgressPercentage / 10)}[{e.ProgressPercentage}]{new string('-', 10 - e.ProgressPercentage / 10)}");
|
{
|
||||||
Console.CursorLeft = 0;
|
Console.Write(
|
||||||
|
$"{new string('=', e.ProgressPercentage / 10)}[{e.ProgressPercentage}]{new string('-', 10 - e.ProgressPercentage / 10)}");
|
||||||
|
Console.CursorLeft = 0;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
client.DownloadDataAsync(link);
|
client.DownloadDataAsync(link);
|
||||||
while (!finished)
|
while (!finished)
|
||||||
|
@ -47,54 +51,67 @@ namespace Installer
|
||||||
|
|
||||||
public bool YesNoDialog(string text, bool defaultVal)
|
public bool YesNoDialog(string text, bool defaultVal)
|
||||||
{
|
{
|
||||||
bool choosing = true;
|
if (Basic)
|
||||||
bool current = defaultVal;
|
|
||||||
Console.WriteLine(text);
|
|
||||||
while (choosing)
|
|
||||||
{
|
{
|
||||||
Console.CursorLeft = 0;
|
Console.WriteLine(text);
|
||||||
Console.BackgroundColor = current ? ConsoleColor.White : ConsoleColor.Black;
|
Console.WriteLine($"Selecting: {defaultVal}");
|
||||||
Console.ForegroundColor = current ? ConsoleColor.Black : ConsoleColor.White;
|
return defaultVal;
|
||||||
Console.Write("Yes");
|
}
|
||||||
Console.ResetColor();
|
else
|
||||||
Console.Write(" ");
|
{
|
||||||
Console.BackgroundColor = current ? ConsoleColor.Black : ConsoleColor.White;
|
bool choosing = true;
|
||||||
Console.ForegroundColor = current ? ConsoleColor.White : ConsoleColor.Black;
|
bool current = defaultVal;
|
||||||
Console.Write("No");
|
Console.WriteLine(text);
|
||||||
Console.ResetColor();
|
while (choosing)
|
||||||
switch (Console.ReadKey().Key)
|
{
|
||||||
{
|
Console.CursorLeft = 0;
|
||||||
case ConsoleKey.LeftArrow:
|
Console.BackgroundColor = current ? ConsoleColor.White : ConsoleColor.Black;
|
||||||
case ConsoleKey.RightArrow:
|
Console.ForegroundColor = current ? ConsoleColor.Black : ConsoleColor.White;
|
||||||
current = !current;
|
Console.Write("Yes");
|
||||||
break;
|
Console.ResetColor();
|
||||||
case ConsoleKey.Enter:
|
Console.Write(" ");
|
||||||
choosing = false;
|
Console.BackgroundColor = current ? ConsoleColor.Black : ConsoleColor.White;
|
||||||
break;
|
Console.ForegroundColor = current ? ConsoleColor.White : ConsoleColor.Black;
|
||||||
case ConsoleKey.Escape:
|
Console.Write("No");
|
||||||
current = defaultVal;
|
Console.ResetColor();
|
||||||
choosing = false;
|
switch (Console.ReadKey().Key)
|
||||||
break;
|
{
|
||||||
}
|
case ConsoleKey.LeftArrow:
|
||||||
|
case ConsoleKey.RightArrow:
|
||||||
|
current = !current;
|
||||||
|
break;
|
||||||
|
case ConsoleKey.Enter:
|
||||||
|
choosing = false;
|
||||||
|
break;
|
||||||
|
case ConsoleKey.Escape:
|
||||||
|
current = defaultVal;
|
||||||
|
choosing = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Console.ResetColor();
|
||||||
|
Console.WriteLine($" Selecting: {current}");
|
||||||
|
return current;
|
||||||
}
|
}
|
||||||
Console.ResetColor();
|
|
||||||
Console.WriteLine($" Selecting: {current}");
|
|
||||||
return current;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OkDialog(string text)
|
public void OkDialog(string text)
|
||||||
{
|
{
|
||||||
Console.WriteLine(text);
|
if (Basic)
|
||||||
Console.BackgroundColor = ConsoleColor.White;
|
Console.WriteLine(text);
|
||||||
Console.Write("OK");
|
else
|
||||||
Console.ResetColor();
|
{
|
||||||
Console.ReadKey();
|
Console.WriteLine(text);
|
||||||
|
Console.BackgroundColor = ConsoleColor.White;
|
||||||
|
Console.Write("OK");
|
||||||
|
Console.ResetColor();
|
||||||
|
Console.ReadKey();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public object GetDefaultIcon() => 0;
|
public object GetDefaultIcon() => 0;
|
||||||
|
|
||||||
public object ImageFromB64(string b64) => 0;
|
public object ImageFromB64(string b64) => 0;
|
||||||
|
|
||||||
public void Log(string text) => Console.WriteLine(text);
|
public void Log(string text) => Console.WriteLine(text);
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -28,7 +28,7 @@ namespace UpToolCLI
|
||||||
Command start = new Command("start", "Starts an app")
|
Command start = new Command("start", "Starts an app")
|
||||||
{
|
{
|
||||||
new Argument<string>("identifier", "Something to identify the app"),
|
new Argument<string>("identifier", "Something to identify the app"),
|
||||||
new Option<string>(new[] {"--waitForExit", "-wait"}, "Waits until the program quits")
|
new Option<bool>(new[] {"--waitForExit", "-wait"}, "Waits until the program quits")
|
||||||
};
|
};
|
||||||
start.Handler = CommandHandler.Create<string, bool>(Start);
|
start.Handler = CommandHandler.Create<string, bool>(Start);
|
||||||
rootCommand.AddCommand(start);
|
rootCommand.AddCommand(start);
|
||||||
|
|
Reference in New Issue
Block a user