Skip to content

Commit

Permalink
Created the Wordler Launcher and a PowerShell run script
Browse files Browse the repository at this point in the history
  • Loading branch information
vesk4000 committed Mar 18, 2022
1 parent 5b7e044 commit 0489bda
Show file tree
Hide file tree
Showing 7 changed files with 107 additions and 44 deletions.
2 changes: 1 addition & 1 deletion Properties/launchSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"profiles": {
"Wordler": {
"commandName": "Project",
"commandLineArgs": "--tl 5"
"commandLineArgs": "--tl 15"
},
"WSL": {
"commandName": "WSL2",
Expand Down
5 changes: 5 additions & 0 deletions Source/CLI/Commands/AppSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
92 changes: 49 additions & 43 deletions Source/CLI/Commands/SolveCommand.cs
Original file line number Diff line number Diff line change
@@ -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<SolveCommand.Settings> {
public class Settings : AppSettings {

}

public override int Execute([NotNull] CommandContext context, [NotNull] Settings settings) {
var task = new LiveTask<string, Solver>();
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<SolveCommand.Settings> {
public class Settings : AppSettings {

}

public override int Execute([NotNull] CommandContext context, [NotNull] Settings settings) {
var task = new LiveTask<string, Solver>();
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;
}
}
}
20 changes: 20 additions & 0 deletions Wordler Launcher/Program.cs
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
9 changes: 9 additions & 0 deletions Wordler Launcher/Wordler Launcher.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>Wordler_Launcher</RootNamespace>
</PropertyGroup>

</Project>
8 changes: 8 additions & 0 deletions Wordler.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,16 @@
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<ApplicationIcon />
<StartupObject />
</PropertyGroup>

<ItemGroup>
<Compile Remove="Wordler Launcher\**" />
<EmbeddedResource Remove="Wordler Launcher\**" />
<None Remove="Wordler Launcher\**" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="PastebinAPI" Version="1.1.1" />
<PackageReference Include="Spectre.Console" Version="0.43.0" />
Expand Down
15 changes: 15 additions & 0 deletions run.ps1
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 0489bda

Please sign in to comment.