Skip to content

Commit

Permalink
Info command
Browse files Browse the repository at this point in the history
  • Loading branch information
DominicAglialoro committed Mar 20, 2023
1 parent c3e36a4 commit 6dfce42
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions SRXDModManager/CommandLine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,13 @@ public CommandLine(ModManager modManager) {

root.AddCommand(CreateCommand("exit", "Exits the application"));

root.AddCommand(CreateCommand("list", "Lists all loaded mods", command => { command.SetHandler(ListMods); }));
root.AddCommand(CreateCommand("info", "Gets detailed information about a mod", command => {
var nameArg = new Argument<string>("name", "The name of the mod");

command.AddCommand(CreateCommand("all", "Gets info for all loaded mods", command => command.SetHandler(GetAllModInfo)));
command.AddArgument(nameArg);
command.SetHandler(GetModInfo, nameArg);
}));

root.AddCommand(CreateCommand("refresh", "Refreshes the list of downloaded mods", command => { command.SetHandler(RefreshMods); }));

Expand Down Expand Up @@ -112,16 +118,21 @@ public void DownloadMod(string repository) {
Console.WriteLine($"Failed to download mod at {repository}: {failureMessage}");
}

public void ListMods() {
public void GetModInfo(string name) {
if (!modManager.TryGetMod(name, out var mod))
Console.WriteLine($"{name} not found");
else
Console.WriteLine($"{mod}: {mod.Description}");
}

public void GetAllModInfo() {
var mods = modManager.GetLoadedMods();

if (mods.Count == 0)
Console.WriteLine("No mods found");
else {
Console.WriteLine($"Found {mods.Count} mod{(mods.Count > 1 ? "s" : string.Empty)}:");

foreach (var mod in mods)
Console.WriteLine(mod);
Console.WriteLine($"{mod}: {mod.Description}");
}
}

Expand Down

0 comments on commit 6dfce42

Please sign in to comment.