Skip to content

Commit

Permalink
126
Browse files Browse the repository at this point in the history
  • Loading branch information
beiranvand-karim committed Oct 6, 2024
1 parent daa9770 commit f9a2034
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ Dictionary<string, string> environmentVariablesSourceDictionary
string wrappedVal = stringHelpers.WrappInQoutationMarks(val);
fileContentDictionaryToWriteToFile.Add(key, wrappedVal ?? "");
}
else if (key == "COMMAND")
{
string wrappedVal = stringHelpers.WrappInQoutationMarks("open");
fileContentDictionaryToWriteToFile.Add(key, wrappedVal ?? "");
}
else if (key == "NOTEPAD_PLUS_PLUS_FILE_MANAGEMENT_EXECUTIVE_FILE_CONTAINING_DIRECTORY")
{
environmentVariablesSourceDictionary.TryGetValue(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ NOTEPADDPP_EXECUTE_FILE_LOCATION=
FEATURE_NAME=
HOSTING_DIRECTORY=
HOST_APPLICATION_NAME=
GUEST_APPLICATION_NAME=
GUEST_APPLICATION_NAME=
COMMAND=
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,6 @@ get-content "notepadpp-open-all.env" | ForEach-Object {
set-content env:\$name $value
}
Push-Location $env:NOTEPAD_PLUS_PLUS_FILE_MANAGEMENT_EXECUTIVE_FILE_CONTAINING_DIRECTORY
$ArgumentList = "--notepaddpp-execute-file-location $env:NOTEPADDPP_EXECUTE_FILE_LOCATION --feature-name $env:FEATURE_NAME --hosting-directory $env:HOSTING_DIRECTORY --host-application-name $env:HOST_APPLICATION_NAME --guest-application-name $env:GUEST_APPLICATION_NAME"
$ArgumentList = "--command $env:COMMAND --notepaddpp-execute-file-location $env:NOTEPADDPP_EXECUTE_FILE_LOCATION --feature-name $env:FEATURE_NAME --hosting-directory $env:HOSTING_DIRECTORY --host-application-name $env:HOST_APPLICATION_NAME --guest-application-name $env:GUEST_APPLICATION_NAME"
start-process -FilePath $env:NOTEPAD_PLUS_PLUS_FILE_MANAGEMENT_EXECUTIVE_FILE_LOCATION -ArgumentList $ArgumentList
Pop-Location
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ private static void Main(string[] args)
.UseSerilog()
.Build();

var svc = ActivatorUtilities.CreateInstance<ProcessManager>(host.Services);
var svc = ActivatorUtilities.CreateInstance<CommandSwitcher>(host.Services);
svc.Run();
}

Expand Down

0 comments on commit f9a2034

Please sign in to comment.