diff --git a/dotnet/notepad-plus-plus-file-management/terminal/notepad-plus-plus-file-management/CommandSwitcher.cs b/dotnet/notepad-plus-plus-file-management/terminal/notepad-plus-plus-file-management/CommandSwitcher.cs new file mode 100644 index 00000000..f1f26264 --- /dev/null +++ b/dotnet/notepad-plus-plus-file-management/terminal/notepad-plus-plus-file-management/CommandSwitcher.cs @@ -0,0 +1,33 @@ +using notepad_plus_plus_file_management.Interfaces; + +namespace notepad_plus_plus_file_management +{ + public class CommandSwitcher( + ICommandLineArgs commandLineArgs, + IProcessManager processManager + ) : ICommandSwitcher + { + private readonly ICommandLineArgs commandLineArgs = commandLineArgs; + private readonly IProcessManager processManager = processManager; + + public string GetCommand() + { + string command = commandLineArgs.GetByKey("--command"); + return command; + } + + public void Run() + { + if (GetCommand() == "open") + { + processManager.Run(); + } + } + } + + public interface ICommandSwitcher + { + public string GetCommand(); + public void Run(); + } +} \ No newline at end of file diff --git a/dotnet/notepad-plus-plus-file-management/terminal/notepad-plus-plus-file-management/Program.cs b/dotnet/notepad-plus-plus-file-management/terminal/notepad-plus-plus-file-management/Program.cs index bd8f8501..08225e08 100644 --- a/dotnet/notepad-plus-plus-file-management/terminal/notepad-plus-plus-file-management/Program.cs +++ b/dotnet/notepad-plus-plus-file-management/terminal/notepad-plus-plus-file-management/Program.cs @@ -46,7 +46,7 @@ private static void Main(string[] args) .UseSerilog() .Build(); - var svc = ActivatorUtilities.CreateInstance(host.Services); + var svc = ActivatorUtilities.CreateInstance(host.Services); svc.Run(); }