Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

117 #336

Draft
wants to merge 31 commits into
base: master
Choose a base branch
from
Draft

117 #336

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 4 additions & 46 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,49 +56,7 @@ component.worker.ps1
module-with-component.worker.ps1
project.worker.ps1

# angular git ignore file
# See http://help.github.com/ignore-files/ for more about ignoring files.

# Compiled output
learnings/angular/slide-in-over-lay/dist
learnings/angular/slide-in-over-lay/tmp
learnings/angular/slide-in-over-lay/out-tsc
learnings/angular/slide-in-over-lay/bazel-out

# Node
learnings/angular/slide-in-over-lay/node_modules
npm-debug.log
yarn-error.log

# IDEs and editors
.idea/
.project
.classpath
.c9/
*.launch
.settings/
*.sublime-workspace

# Visual Studio Code
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
.history/*

# Miscellaneous
learnings/angular/slide-in-over-lay/.angular/cache
.sass-cache/
learnings/angular/slide-in-over-lay/connect.lock
learnings/angular/slide-in-over-lay/coverage
learnings/angular/slide-in-over-lay/libpeerconnection.log
testem.log
learnings/angular/slide-in-over-lay/typings

# System files
.DS_Store
Thumbs.db



# local development settings files
appsettings.Development.json
dotnet/notepad-plus-plus-file-management/settings/notepad-plus-plus-file-management/appsettings.json
dotnet/notepad-plus-plus-file-management/terminal/notepad-plus-plus-file-management/appsettings.json
36 changes: 36 additions & 0 deletions WorkingCirculation/DirectoryManagement/CommandLineArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
using Microsoft.Extensions.Configuration;

namespace DirectoryManagement
{
public class CommandLineArgs(IConfiguration configuration) : ICommandLineArgs
{
private readonly IConfiguration configuration = configuration;

public string GetKey(string key)
{
string groupKey = "EnvironmentVariablesCommandLineArgumentsNameKeys";
string commandLineArgumentKey = $""""{groupKey}:{key}"""";
return configuration.GetValue<string>(commandLineArgumentKey) ?? $"""could'nt find key "{key}" ...""";
}

public string GetKey2(string groupKey, string key)
{
string commandLineArgumentKey = $""""{groupKey}:{key}"""";
return configuration.GetValue<string>(commandLineArgumentKey) ?? $"""could'nt find key "{key}" ...""";
}

public string GetByKey(string CommandLineArgKey)
{
var commandLineArgs = Environment.GetCommandLineArgs();

int index = Array.FindIndex(commandLineArgs, x => x.StartsWith(CommandLineArgKey));
if (index > -1)
{
string CommandLineArgValue = commandLineArgs[index + 1];
return CommandLineArgValue;
}

return $"""could'nt find environment variable "{CommandLineArgKey}" ...""";
}
}
}
15 changes: 15 additions & 0 deletions WorkingCirculation/DirectoryManagement/DirectoryManagement.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,19 @@
<Nullable>enable</Nullable>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Serilog.Extensions.Hosting" Version="8.0.0" />
<PackageReference Include="Serilog.Settings.Configuration" Version="8.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="6.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Debug'">
<None Update="appsettings.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

<ItemGroup Condition="'$(Configuration)' == 'Release'">
<None Update="appsettings.json" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>

</Project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 17
VisualStudioVersion = 17.5.002.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DirectoryManagement", "DirectoryManagement.csproj", "{ECD85DFF-E204-48AA-B3AB-C175D3C8A254}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{ECD85DFF-E204-48AA-B3AB-C175D3C8A254}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{ECD85DFF-E204-48AA-B3AB-C175D3C8A254}.Debug|Any CPU.Build.0 = Debug|Any CPU
{ECD85DFF-E204-48AA-B3AB-C175D3C8A254}.Release|Any CPU.ActiveCfg = Release|Any CPU
{ECD85DFF-E204-48AA-B3AB-C175D3C8A254}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {36E1DD06-6C7D-47EA-B810-3C65492B57DB}
EndGlobalSection
EndGlobal
34 changes: 34 additions & 0 deletions WorkingCirculation/DirectoryManagement/DirectoryManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
using Microsoft.Extensions.Logging;

namespace DirectoryManagement
{
public interface IDirectoryManager
{
public void Run();
}

public class DirectoryManager(
ILogger<DirectoryManager> logger,
IDirectoryOperations directoryOperations,
IDirectoryToBeOpen directoryToBeOpen
) : IDirectoryManager
{
private readonly ILogger<DirectoryManager> logger = logger;
private readonly IDirectoryOperations directoryOperations = directoryOperations;
private readonly IDirectoryToBeOpen directoryToBeOpen = directoryToBeOpen;

public void Run()
{
try
{
string workingDirectory = directoryToBeOpen.GetPath();
directoryOperations.OpenDirectoryThroughExplorer(workingDirectory);
}
catch (Exception exception)
{
logger.LogInformation("Exception: {exception}", exception);
}

}
}
}
30 changes: 14 additions & 16 deletions WorkingCirculation/DirectoryManagement/DirectoryOperations.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
using System.Diagnostics;
using Microsoft.Extensions.Logging;

namespace DirectoryManagement
{
internal class DirectoryOperations {
public static void OpenDirectoryThroughExplorer(string directoryPath){
if(Directory.Exists(directoryPath))
public interface IDirectoryOperations
{
public void OpenDirectoryThroughExplorer(string directoryPath);

}
public class DirectoryOperations(ILogger<DirectoryOperations> logger) : IDirectoryOperations
{
private readonly ILogger<DirectoryOperations> logger = logger;

public void OpenDirectoryThroughExplorer(string directoryPath)
{
if (Directory.Exists(directoryPath))
{
ProcessStartInfo startInfo = new ProcessStartInfo
ProcessStartInfo startInfo = new()
{
Arguments = directoryPath,
FileName = "explorer.exe"
Expand All @@ -15,17 +25,5 @@ public static void OpenDirectoryThroughExplorer(string directoryPath){
}

}

public static void OpenDirectoryThroughCommandLine(string commandToExecute, string workingDirectory) {
Process process = new Process();
process.StartInfo.WorkingDirectory = workingDirectory;
process.StartInfo.FileName = "cmd.exe";
process.StartInfo.Arguments = $"/c {commandToExecute}";
process.StartInfo.RedirectStandardOutput= true;
process.Start();
process.WaitForExit();
string output = process.StandardOutput.ReadToEnd();
Console.WriteLine(output);
}
}
}
23 changes: 23 additions & 0 deletions WorkingCirculation/DirectoryManagement/DirectoryToBeOpen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;

namespace DirectoryManagement
{
public class DirectoryToBeOpen(
IConfiguration configuration,
ICommandLineArgs commandLineArgs,
ILogger<DirectoryToBeOpen> logger
) : IDirectoryToBeOpen
{
private readonly IConfiguration configuration = configuration;
private readonly ICommandLineArgs commandLineArgs = commandLineArgs;
private readonly ILogger<DirectoryToBeOpen> logger = logger;

string IDirectoryToBeOpen.GetPath()
{
var directoryToBeOpen = commandLineArgs.GetByKey("--directory-to-be-open");
logger.LogInformation("directory to be open: {directoryToBeOpen}", directoryToBeOpen);
return directoryToBeOpen;
}
}
}
9 changes: 9 additions & 0 deletions WorkingCirculation/DirectoryManagement/ICommandLineArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace DirectoryManagement
{
public interface ICommandLineArgs
{
public string GetKey(string key);
public string GetKey2(string groupKey, string key);
public string GetByKey(string CommandLineArgKey);
}
}
7 changes: 7 additions & 0 deletions WorkingCirculation/DirectoryManagement/IDirectoryToBeOpen.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
namespace DirectoryManagement
{
public interface IDirectoryToBeOpen
{
public string GetPath();
}
}
52 changes: 41 additions & 11 deletions WorkingCirculation/DirectoryManagement/Program.cs
Original file line number Diff line number Diff line change
@@ -1,15 +1,45 @@
using DirectoryManagement;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Serilog;

string choice = "2";
string workingDirectory = Environment.GetCommandLineArgs()[1];

if(choice == "1")
internal class Program
{
string commandToExecute = Environment.GetCommandLineArgs()[2];
DirectoryOperations.OpenDirectoryThroughCommandLine(commandToExecute, workingDirectory);
}
private static void Main(string[] args)
{

if(choice == "2")
{
DirectoryOperations.OpenDirectoryThroughExplorer(workingDirectory);
}
var builder = new ConfigurationBuilder();
BuildConfig(builder);

Log.Logger = new LoggerConfiguration()
.ReadFrom.Configuration(builder.Build())
.Enrich.FromLogContext()
.WriteTo.Console()
.CreateLogger();

var host = Host.CreateDefaultBuilder()
.ConfigureServices((context, services) =>
{
services.AddTransient<IDirectoryManager, DirectoryManager>();
services.AddTransient<IDirectoryOperations, DirectoryOperations>();
services.AddTransient<ICommandLineArgs, CommandLineArgs>();
services.AddTransient<IDirectoryToBeOpen, DirectoryToBeOpen>();
})
.UseSerilog()
.Build();

var svc = ActivatorUtilities.CreateInstance<DirectoryManager>(host.Services);
svc.Run();

}


static void BuildConfig(IConfigurationBuilder builder)
{
builder.SetBasePath(Directory.GetCurrentDirectory())
.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true)
.AddJsonFile($"appsettings.{Environment.GetEnvironmentVariable("ASPNETCORE_ENVIRONMENT") ?? "Prodcution"}.json", optional: true)
.AddEnvironmentVariables();
}
}
11 changes: 11 additions & 0 deletions WorkingCirculation/DirectoryManagement/appsettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"Serilog": {
"MinimumLevel": {
"Default": "Information",
"Override": {
"Microsoft": "Information",
"System": "Warning"
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using cross_application_feature_development_management.Combiners.Interfaces;
using cross_application_feature_development_management.Dirctories.Feature.EnvironmentVariablesTemplateFiles;
using cross_application_feature_development_management.Dirctories.Interfaces;
using cross_application_feature_development_management.Interfaces;
using cross_application_feature_development_management.Names.Classses;
Expand All @@ -18,7 +19,8 @@ public class CrossApplicationFeatureDevelopmentManagement(
IPowerShellScriptsDirectory powerShellScriptsDirectory,
IBatchScriptsDicrectory batchScriptsDicrectory,
ISomething something,
IAddToStartupScript addToStartupScript
IAddToStartupScript addToStartupScript,
INotePadPlusPlusOpenAll notePadPlusPlusOpenAll
)
: ICrossApplicationFeatureDevelopmentManagement
{
Expand All @@ -33,6 +35,7 @@ IAddToStartupScript addToStartupScript
private readonly IBatchScriptsDicrectory batchScriptsDicrectory = batchScriptsDicrectory;
private readonly ISomething something = something;
private readonly IAddToStartupScript addToStartupScript = addToStartupScript;
private readonly INotePadPlusPlusOpenAll notePadPlusPlusOpenAll = notePadPlusPlusOpenAll;

public void Run()
{
Expand Down Expand Up @@ -72,6 +75,11 @@ public void Run()
contentToWrite =
addToStartupScript.PairUpVariablesWithTheirValue(templateFile, environmentVariablesSourceDictionary);
}
else if (templateFile.Contains("notepadpp-open-all"))
{
contentToWrite =
notePadPlusPlusOpenAll.PairUpVariablesWithTheirValue(templateFile, environmentVariablesSourceDictionary);
}
else
{
contentToWrite =
Expand Down
Loading