Skip to content

Commit

Permalink
rem - brk|doc - Removed command type from CommandInfo
Browse files Browse the repository at this point in the history
---

We've made a breaking change which involves the Type property in CommandInfo. This property was rendered useless due to the improvements on command registration. RegisterCustomCommand() and its siblings already take shell type, so why have CommandInfo hold the shell type and make things difficult?

---

Type: rem
Breaking: True
Doc Required: True
Part: 1/1
  • Loading branch information
AptiviCEO committed Oct 31, 2023
1 parent 3ed1264 commit dfa9dea
Show file tree
Hide file tree
Showing 42 changed files with 406 additions and 449 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void TestGetMethodStatic()
[Description("Management")]
public void TestGetMethod()
{
var instance = new CommandInfo("cmd", ShellType.Shell, "Test me!", Array.Empty<CommandArgumentInfo>(), null);
var instance = new CommandInfo("cmd", "Test me!", Array.Empty<CommandArgumentInfo>(), null);
var value = MethodManager.GetMethod(nameof(instance.GetTranslatedHelpEntry), instance.GetType());
value.ShouldNotBeNull();
value.DeclaringType.ShouldBe(instance.GetType());
Expand All @@ -78,7 +78,7 @@ public void TestInvokeMethodStatic()
[Description("Management")]
public void TestInvokeMethod()
{
var instance = new CommandInfo("cmd", ShellType.Shell, "Test me!", Array.Empty<CommandArgumentInfo>(), null);
var instance = new CommandInfo("cmd", "Test me!", Array.Empty<CommandArgumentInfo>(), null);
var value = MethodManager.InvokeMethod(nameof(instance.GetTranslatedHelpEntry), instance);
value.ShouldNotBeNull();
value.ShouldBeOfType(typeof(string));
Expand Down

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void TestIsCommandFoundInAllTheShells() =>
public void TestRegisterCommand(ShellType type)
{
Should.NotThrow(() => CommandManager.RegisterCustomCommand(type,
new CommandInfo("mycmd", type, "My command help definition...",
new CommandInfo("mycmd", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
Expand Down Expand Up @@ -129,7 +129,7 @@ public void TestRegisterCommand(ShellType type)
public void TestRegisterCommand(string type)
{
Should.NotThrow(() => CommandManager.RegisterCustomCommand(type,
new CommandInfo("mycmd2", type, "My command help definition...",
new CommandInfo("mycmd2", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
Expand Down Expand Up @@ -158,7 +158,7 @@ public void TestRegisterCommand(string type)
public void TestRegisterEmptyCommandName(ShellType type)
{
Should.Throw(() => CommandManager.RegisterCustomCommand(type,
new CommandInfo("", type, "My command help definition...",
new CommandInfo("", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
Expand Down Expand Up @@ -186,7 +186,7 @@ public void TestRegisterEmptyCommandName(ShellType type)
public void TestRegisterEmptyCommandName(string type)
{
Should.Throw(() => CommandManager.RegisterCustomCommand(type,
new CommandInfo("", type, "My command help definition...",
new CommandInfo("", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
Expand Down Expand Up @@ -214,7 +214,7 @@ public void TestRegisterEmptyCommandName(string type)
public void TestRegisterCommandConflicting(ShellType type)
{
Should.Throw(() => CommandManager.RegisterCustomCommand(type,
new CommandInfo("exit", type, "My command help definition...",
new CommandInfo("exit", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
Expand Down Expand Up @@ -242,7 +242,7 @@ public void TestRegisterCommandConflicting(ShellType type)
public void TestRegisterCommandConflicting(string type)
{
Should.Throw(() => CommandManager.RegisterCustomCommand(type,
new CommandInfo("exit", type, "My command help definition...",
new CommandInfo("exit", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
Expand Down Expand Up @@ -437,19 +437,19 @@ public void TestRegisterCommands(ShellType type)
{
var commandInfos = new CommandInfo[]
{
new CommandInfo("cmdgroup", type, "My command help definition...",
new CommandInfo("cmdgroup", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
}, new CustomCommand()),

new CommandInfo("cmdgroup1", type, "My command help definition...",
new CommandInfo("cmdgroup1", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
}, new CustomCommand()),

new CommandInfo("cmdgroup2", type, "My command help definition...",
new CommandInfo("cmdgroup2", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
Expand Down Expand Up @@ -482,19 +482,19 @@ public void TestRegisterCommands(string type)
{
var commandInfos = new CommandInfo[]
{
new CommandInfo("cmdgroup3", type, "My command help definition...",
new CommandInfo("cmdgroup3", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
}, new CustomCommand()),

new CommandInfo("cmdgroup4", type, "My command help definition...",
new CommandInfo("cmdgroup4", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
}, new CustomCommand()),

new CommandInfo("cmdgroup5", type, "My command help definition...",
new CommandInfo("cmdgroup5", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
Expand Down Expand Up @@ -527,19 +527,19 @@ public void TestRegisterCommandsWithErrors(ShellType type)
{
var commandInfos = new CommandInfo[]
{
new CommandInfo("command", type, "My command help definition...",
new CommandInfo("command", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
}, new CustomCommand()),

new CommandInfo("exit", type, "My command help definition...",
new CommandInfo("exit", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
}, new CustomCommand()),

new CommandInfo("", type, "My command help definition...",
new CommandInfo("", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
Expand Down Expand Up @@ -570,19 +570,19 @@ public void TestRegisterCommandsWithErrors(string type)
{
var commandInfos = new CommandInfo[]
{
new CommandInfo("command2", type, "My command help definition...",
new CommandInfo("command2", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
}, new CustomCommand()),

new CommandInfo("exit", type, "My command help definition...",
new CommandInfo("exit", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
}, new CustomCommand()),

new CommandInfo("", type, "My command help definition...",
new CommandInfo("", $"My command help definition for type {type}...",
new[]
{
new CommandArgumentInfo()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ShellInfoTest : BaseShellInfo, IShellInfo
public override Dictionary<string, CommandInfo> Commands => new()
{
{ "test",
new CommandInfo("test", ShellType, "Test command", new[] {
new CommandInfo("test", "Test command", new[] {
new CommandArgumentInfo()
}, null)
},
Expand Down
24 changes: 12 additions & 12 deletions public/Nitrocid.Addons/Nitrocid.Extras.Amusements/AmusementsInit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ internal class AmusementsInit : IAddon
private readonly Dictionary<string, CommandInfo> addonCommands = new()
{
{ "backrace",
new CommandInfo("backrace", ShellType.Shell, /* Localizable */ "Do you back the wrong horse?",
new CommandInfo("backrace", /* Localizable */ "Do you back the wrong horse?",
new[] {
new CommandArgumentInfo()
}, new BackRaceCommand())
},

{ "hangman",
new CommandInfo("hangman", ShellType.Shell, /* Localizable */ "Starts the Hangman game",
new CommandInfo("hangman", /* Localizable */ "Starts the Hangman game",
new[] {
new CommandArgumentInfo(new[] {
new SwitchInfo("hardcore", /* Localizable */ "One wrong letter and you're hung!", new SwitchOptions()
Expand All @@ -64,49 +64,49 @@ internal class AmusementsInit : IAddon
},

{ "meteor",
new CommandInfo("meteor", ShellType.Shell, /* Localizable */ "You are a spaceship and the meteors are coming to destroy you. Can you save it?",
new CommandInfo("meteor", /* Localizable */ "You are a spaceship and the meteors are coming to destroy you. Can you save it?",
new[] {
new CommandArgumentInfo()
}, new MeteorCommand())
},

{ "quote",
new CommandInfo("quote", ShellType.Shell, /* Localizable */ "Gets a random quote",
new CommandInfo("quote", /* Localizable */ "Gets a random quote",
new[] {
new CommandArgumentInfo()
}, new QuoteCommand())
},

{ "roulette",
new CommandInfo("roulette", ShellType.Shell, /* Localizable */ "Russian Roulette",
new CommandInfo("roulette", /* Localizable */ "Russian Roulette",
new[] {
new CommandArgumentInfo()
}, new RouletteCommand())
},

{ "shipduet",
new CommandInfo("shipduet", ShellType.Shell, /* Localizable */ "Two spaceships are on a fight with each other. One shot and the spaceship will blow. This is a local two-player game.",
new CommandInfo("shipduet", /* Localizable */ "Two spaceships are on a fight with each other. One shot and the spaceship will blow. This is a local two-player game.",
new[] {
new CommandArgumentInfo()
}, new ShipDuetCommand())
},

{ "snaker",
new CommandInfo("snaker", ShellType.Shell, /* Localizable */ "The snake game!",
new CommandInfo("snaker", /* Localizable */ "The snake game!",
new[] {
new CommandArgumentInfo()
}, new SnakerCommand())
},

{ "solver",
new CommandInfo("solver", ShellType.Shell, /* Localizable */ "See if you can solve mathematical equations on time",
new CommandInfo("solver", /* Localizable */ "See if you can solve mathematical equations on time",
new[] {
new CommandArgumentInfo()
}, new SolverCommand())
},

{ "speedpress",
new CommandInfo("speedpress", ShellType.Shell, /* Localizable */ "See if you can press a key on time",
new CommandInfo("speedpress", /* Localizable */ "See if you can press a key on time",
new[] {
new CommandArgumentInfo(new[] {
new SwitchInfo("e", /* Localizable */ "Starts the game in easy difficulty", new SwitchOptions()
Expand Down Expand Up @@ -139,7 +139,7 @@ internal class AmusementsInit : IAddon
},

{ "wordle",
new CommandInfo("wordle", ShellType.Shell, /* Localizable */ "The Wordle game simulator",
new CommandInfo("wordle", /* Localizable */ "The Wordle game simulator",
new[] {
new CommandArgumentInfo(new[] {
new SwitchInfo("orig", /* Localizable */ "Play the Wordle game originally", new SwitchOptions()
Expand All @@ -152,14 +152,14 @@ internal class AmusementsInit : IAddon

// Hidden
{ "2015",
new CommandInfo("2015", ShellType.Shell, /* Localizable */ "Starts the joke program, HDD Uncleaner 2015.",
new CommandInfo("2015", /* Localizable */ "Starts the joke program, HDD Uncleaner 2015.",
new[] {
new CommandArgumentInfo()
}, new HddUncleanerCommand(), CommandFlags.Hidden)
},

{ "2018",
new CommandInfo("2018", ShellType.Shell, /* Localizable */ "Commemorates the 5-year anniversary of the kernel release",
new CommandInfo("2018", /* Localizable */ "Commemorates the 5-year anniversary of the kernel release",
new[] {
new CommandArgumentInfo()
}, new AnniversaryCommand(), CommandFlags.Hidden)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,14 +40,14 @@ internal class ArchiveShellInfo : BaseShellInfo, IShellInfo
public override Dictionary<string, CommandInfo> Commands => new()
{
{ "cdir",
new CommandInfo("cdir", ShellType, /* Localizable */ "Gets current local directory",
new CommandInfo("cdir", /* Localizable */ "Gets current local directory",
new[] {
new CommandArgumentInfo()
}, new CDirCommand())
},

{ "chdir",
new CommandInfo("chdir", ShellType, /* Localizable */ "Changes directory",
new CommandInfo("chdir", /* Localizable */ "Changes directory",
new[] {
new CommandArgumentInfo(new[]
{
Expand All @@ -57,7 +57,7 @@ internal class ArchiveShellInfo : BaseShellInfo, IShellInfo
},

{ "chadir",
new CommandInfo("chadir", ShellType, /* Localizable */ "Changes archive directory",
new CommandInfo("chadir", /* Localizable */ "Changes archive directory",
new[] {
new CommandArgumentInfo(new[]
{
Expand All @@ -67,7 +67,7 @@ internal class ArchiveShellInfo : BaseShellInfo, IShellInfo
},

{ "get",
new CommandInfo("get", ShellType, /* Localizable */ "Extracts a file to a specified directory or a current directory",
new CommandInfo("get", /* Localizable */ "Extracts a file to a specified directory or a current directory",
new[] {
new CommandArgumentInfo(new[]
{
Expand All @@ -80,7 +80,7 @@ internal class ArchiveShellInfo : BaseShellInfo, IShellInfo
},

{ "list",
new CommandInfo("list", ShellType, /* Localizable */ "Lists all files inside the archive",
new CommandInfo("list", /* Localizable */ "Lists all files inside the archive",
new[] {
new CommandArgumentInfo(new[]
{
Expand All @@ -90,7 +90,7 @@ internal class ArchiveShellInfo : BaseShellInfo, IShellInfo
},

{ "pack",
new CommandInfo("pack", ShellType, /* Localizable */ "Packs a local file to the archive",
new CommandInfo("pack", /* Localizable */ "Packs a local file to the archive",
new[] {
new CommandArgumentInfo(new[]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ internal class ArchiveShellInit : IAddon
private readonly Dictionary<string, CommandInfo> addonCommands = new()
{
{ "archive",
new CommandInfo("archive", ShellType.Shell, /* Localizable */ "Opens the archive file to the archive shell",
new CommandInfo("archive", /* Localizable */ "Opens the archive file to the archive shell",
new[] {
new CommandArgumentInfo(new[]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal class BassBoomInit : IAddon
private readonly Dictionary<string, CommandInfo> addonCommands = new()
{
{ "playlyric",
new CommandInfo("playlyric", ShellType.Shell, /* Localizable */ "Plays a lyric file",
new CommandInfo("playlyric", /* Localizable */ "Plays a lyric file",
new[] {
new CommandArgumentInfo(new[]
{
Expand All @@ -88,7 +88,7 @@ internal class BassBoomInit : IAddon
}, new PlayLyricCommand())
},
{ "playsound",
new CommandInfo("playsound", ShellType.Shell, /* Localizable */ "Plays a sound",
new CommandInfo("playsound", /* Localizable */ "Plays a sound",
new[] {
new CommandArgumentInfo(new[]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal class CalculatorsInit : IAddon
private readonly Dictionary<string, CommandInfo> addonCommands = new()
{
{ "calc",
new CommandInfo("calc", ShellType.Shell, /* Localizable */ "Calculator to calculate expressions.",
new CommandInfo("calc", /* Localizable */ "Calculator to calculate expressions.",
new[] {
new CommandArgumentInfo(new[]
{
Expand All @@ -44,7 +44,7 @@ internal class CalculatorsInit : IAddon
},

{ "imaginary",
new CommandInfo("imaginary", ShellType.Shell, /* Localizable */ "Show information about the imaginary number formula specified by a specified real and imaginary number",
new CommandInfo("imaginary", /* Localizable */ "Show information about the imaginary number formula specified by a specified real and imaginary number",
new[] {
new CommandArgumentInfo(new[]
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public static void PrintCalendar(int Year, int Month, CalendarTypes calendar = C
if (CurrentDate.DayOfWeek == 0)
CurrentWeek += 1;
int CurrentWeekIndex = CurrentWeek - 1;
string CurrentDayMark = $" {CurrentDay} ";
string CurrentDayMark;
bool ReminderMarked = false;
bool EventMarked = false;
bool IsWeekend = CurrentDate.DayOfWeek == DayOfWeek.Friday || CurrentDate.DayOfWeek == DayOfWeek.Saturday;
Expand Down
Loading

0 comments on commit dfa9dea

Please sign in to comment.