-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: simple help command, improvements to the operational flow
- Loading branch information
1 parent
9671c67
commit ceff940
Showing
11 changed files
with
206 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"version": "2.0.0", | ||
"tasks": [ | ||
{ | ||
"type": "shell", | ||
"command": "dotnet build /Users/aaron/Repositories/RTWLibTools/RTWLib_CLI/RTWLib_CLI.csproj --output \"/Users/aaron/Library/Application Support/Feral Interactive/Total War ROME REMASTERED/\" /property:GenerateFullPaths=true /consoleloggerparameters:NoSummary /p:Configuration=Debug /p:Platform=\"AnyCPU\"", | ||
"group": "build", | ||
"problemMatcher": [], | ||
"label": "dotnet: build" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
namespace RTWLib_CLI.cmd.modules; | ||
|
||
using RTWLib_CLI; | ||
using RTWLib_CLI.draw; | ||
using RTWLibPlus.helpers; | ||
|
||
public class Help | ||
{ | ||
string title; | ||
|
||
public string help() | ||
{ | ||
string methods = CLIHelper.GetMethodList(typeof(Help)); | ||
title = string.Format("RTWLib CLI\nHelp\n---\nTry the following commands in\nformat [name] [arg1] [arg2] etc\n---\n{0}", methods).ApplyBorder('#', 2); | ||
|
||
return CLIHelper.ScreenChangeRTN(title); | ||
|
||
|
||
} | ||
|
||
public string Templates() => "You can view available templates by typing 'templates'\nYou can run a tempalte by typing 'run template_name.txt' where template_name is the name of the template you want to run"; | ||
|
||
public string Randomiser() => | ||
"The Randomiser tool can be navigated by typing commands, excluding the apostrophes. the following are some of the commands and descriptors.\n\n" + | ||
"'templates': Access the template menu to start a randomisation.\n" + | ||
"'help': The help menu, you're here right now.\n" + | ||
"'back': Go back a menu"; | ||
public string Test(params string[] args) | ||
{ | ||
string argsStr = args.ToString(','); | ||
return "response: " + argsStr; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
namespace RTWLib_CLI.cmd.screens; | ||
|
||
using System; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
using System.Text; | ||
using RTWLib_CLI.draw; | ||
using RTWLibPlus.helpers; | ||
using RTWLibPlus.parsers; | ||
|
||
public class Templates | ||
{ | ||
private static readonly CompositeFormat TemplatesTitle = CompositeFormat.Parse("Please select a template from below by typing the following 'run template_name.txt': {0}{1}"); | ||
|
||
private readonly Dictionary<string, string[]> templates = []; | ||
|
||
private readonly string title; | ||
public Templates() | ||
{ | ||
this.LoadTemplates(); | ||
this.title = string.Format(null, TemplatesTitle, "\n", this.templates.Keys.ToArray().ArrayToString(false, true, true, 1, false, false)); | ||
} | ||
|
||
public string Action(string cmd) | ||
{ | ||
string[] cmdSplit = cmd.Split(" "); | ||
if (cmdSplit.Length == 1) | ||
{ | ||
return "run command invalid"; | ||
} | ||
|
||
if (this.templates.ContainsKey(cmdSplit[1])) | ||
{ | ||
return this.ProcessTemplate(cmdSplit[1]); | ||
} | ||
|
||
else | ||
{ | ||
return string.Format("Template not found: {0}", cmdSplit[1]); | ||
} | ||
} | ||
|
||
public string View_Templates() => CLIHelper.ScreenChangeRTN(this.title.ApplyBorder('=', 1, 1)); | ||
|
||
private string ProcessTemplate(string template) | ||
{ | ||
string[] cmds = this.templates[template]; | ||
Console.WriteLine("Running: " + template); | ||
//Progress p = new(1f / cmds.Length, "Running: " + template); | ||
foreach (string cmd in cmds) | ||
{ | ||
Console.WriteLine("Doing: " + cmd); | ||
//p.Message("Doing: " + cmd); | ||
CMDProcess.CMDScreener(cmd); | ||
//p.Update("Complete"); | ||
} | ||
return "template finished processing"; | ||
} | ||
|
||
private string LoadTemplates() | ||
{ | ||
if (!Directory.Exists("randomiser_templates")) | ||
{ | ||
return "Template folder does not exist. Skipping template loading"; | ||
} | ||
|
||
string[] files = Directory.GetFiles("randomiser_templates"); | ||
|
||
DepthParse dp = new(); | ||
|
||
foreach (string file in files) | ||
{ | ||
string name = Path.GetFileName(file); | ||
string[] parse = dp.ReadFile(file); | ||
this.templates.Add(name, parse); | ||
} | ||
return "Templates Loaded"; | ||
} | ||
|
||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.