diff --git a/Properties/launchSettings.json b/Properties/launchSettings.json index 1326809..2610aaf 100644 --- a/Properties/launchSettings.json +++ b/Properties/launchSettings.json @@ -2,7 +2,7 @@ "profiles": { "Wordler": { "commandName": "Project", - "commandLineArgs": "--tl 5" + "commandLineArgs": "--tl 15" }, "WSL": { "commandName": "WSL2", diff --git a/Source/CLI/Commands/AppSettings.cs b/Source/CLI/Commands/AppSettings.cs index 0a2fed6..2b7d342 100644 --- a/Source/CLI/Commands/AppSettings.cs +++ b/Source/CLI/Commands/AppSettings.cs @@ -71,6 +71,11 @@ class AppSettings : CommandSettings { [DefaultValue(3_600_000)] public int TimeLimit { get; set; } + [Description("PowerShell commands to execute after Wordler has finished")] + [CommandOption("--ps|--powershell|--ps1")] + [DefaultValue("")] + public string PowerShellCommands { get; set; } + public WordClues wordClues; public PastebinAPI.User user; diff --git a/Source/CLI/Commands/SolveCommand.cs b/Source/CLI/Commands/SolveCommand.cs index 09f9a4d..c11f6e6 100644 --- a/Source/CLI/Commands/SolveCommand.cs +++ b/Source/CLI/Commands/SolveCommand.cs @@ -1,43 +1,49 @@ -using System; -using System.Collections.Generic; -using System.Diagnostics.CodeAnalysis; -using System.Linq; -using System.Text; -using System.Threading.Tasks; -using Spectre.Console; -using Spectre.Console.Cli; -using System.Threading; -using System.Diagnostics; -using System.IO; - -namespace Wordler { - class SolveCommand : Command { - public class Settings : AppSettings { - - } - - public override int Execute([NotNull] CommandContext context, [NotNull] Settings settings) { - var task = new LiveTask(); - task.Run(new Solver( - settings.Hard, - settings.WordList, - settings.LeaderboardLength, - settings.Threads, - settings.wordClues, - Extensions.GetSolutionType(settings.SolutionName), - settings.Divide - ), settings.TimeLimit); - - if(settings.user is not null) - settings.user.CreatePasteAsync - ( - File.ReadAllText(Cacher.path), - "Wordler Cache " + DateTime.Now.ToString(), - PastebinAPI.Language.XML, - PastebinAPI.Visibility.Private - ).Wait(); - - return 0; - } - } -} +using System; +using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Spectre.Console; +using Spectre.Console.Cli; +using System.Threading; +using System.Diagnostics; +using System.IO; + +namespace Wordler { + class SolveCommand : Command { + public class Settings : AppSettings { + + } + + public override int Execute([NotNull] CommandContext context, [NotNull] Settings settings) { + var task = new LiveTask(); + task.Run(new Solver( + settings.Hard, + settings.WordList, + settings.LeaderboardLength, + settings.Threads, + settings.wordClues, + Extensions.GetSolutionType(settings.SolutionName), + settings.Divide + ), settings.TimeLimit); + + if(settings.user is not null) + settings.user.CreatePasteAsync + ( + File.ReadAllText(Cacher.path), + "Wordler Cache " + DateTime.Now.ToString(), + PastebinAPI.Language.XML, + PastebinAPI.Visibility.Private + ).Wait(); + + if(settings.PowerShellCommands != "") + { + var psc = new ProcessStartInfo("powershell.exe", " -Command { " + settings.PowerShellCommands.Replace("@ID", Process.GetCurrentProcess().Id.ToString() + " }")); + Process.Start(psc); + } + + return 0; + } + } +} diff --git a/Wordler Launcher/Program.cs b/Wordler Launcher/Program.cs new file mode 100644 index 0000000..e4ecbd7 --- /dev/null +++ b/Wordler Launcher/Program.cs @@ -0,0 +1,20 @@ +using System; +using System.Diagnostics; +using System.IO; + +namespace Wordler_Launcher +{ + class Program + { + static void Main(string[] args) + { + Process wordler = new Process(); + wordler.StartInfo.FileName = Directory.GetCurrentDirectory() + "\\Wordler.exe"; + wordler.StartInfo.UseShellExecute = false; + wordler.StartInfo.CreateNoWindow = true; + wordler.StartInfo.Arguments = "--tl 15 --ps \" Wait-Process -Id @ID; $directorypath = (Get-Item .).FullName; $path = $directorypath + '\\Wordlerer\\';If (!(test-path $path)) { mkdir $path }; Remove-Item $directorypath; \""; + wordler.Start(); + return; + } + } +} diff --git a/Wordler Launcher/Wordler Launcher.csproj b/Wordler Launcher/Wordler Launcher.csproj new file mode 100644 index 0000000..03cedaf --- /dev/null +++ b/Wordler Launcher/Wordler Launcher.csproj @@ -0,0 +1,9 @@ + + + + Exe + net5.0 + Wordler_Launcher + + + diff --git a/Wordler.csproj b/Wordler.csproj index 2c608a7..63156d7 100644 --- a/Wordler.csproj +++ b/Wordler.csproj @@ -3,8 +3,16 @@ Exe net5.0 + + + + + + + + diff --git a/run.ps1 b/run.ps1 new file mode 100644 index 0000000..3758a20 --- /dev/null +++ b/run.ps1 @@ -0,0 +1,15 @@ +$directorypath = (Get-Item .).FullName + +$path = $directorypath + '\Wordler\' +If (!(test-path $path)) { mkdir $path } + +$url = 'https://github.com/vesk4000/Wordler/releases/download/v1.2.1/wordlist.txt' +$path_to_file = $directorypath + '\Wordler\wordlist.txt' +Invoke-WebRequest $url -OutFile $path_to_file + +$url = 'https://github.com/vesk4000/Wordler/releases/download/v1.2.1/Wordler.exe' +$path_to_file = $directorypath + '\Wordler\Wordler.exe' +$directory_to_file = $directorypath + '\Wordler\' +Invoke-WebRequest $url -OutFile $path_to_file + +Start-Process -FilePath 'Wordler\Wordler Launcher.exe' -WorkingDirectory $directory_to_file \ No newline at end of file