diff --git a/MasterCommander.sln.DotSettings.user b/MasterCommander.sln.DotSettings.user index 38c21eb..6a2a330 100644 --- a/MasterCommander.sln.DotSettings.user +++ b/MasterCommander.sln.DotSettings.user @@ -1,5 +1,5 @@  - /Users/phmatray/Library/Caches/JetBrains/Rider2023.3/resharper-host/temp/Rider/vAny/CoverageData/_MasterCommander.1386933053/Snapshot/snapshot.utdcvr + <SessionState ContinuousTestingIsOn="True" ContinuousTestingMode="3" IsActive="True" Name="All tests from &lt;MasterCommander.Tests&gt;" xmlns="urn:schemas-jetbrains-com:jetbrains-ut-session"> diff --git a/docs/links b/docs/links index fab0d32..6765c51 100644 --- a/docs/links +++ b/docs/links @@ -7,7 +7,9 @@ P:MasterCommander.Integrations.DirectoryService.HomeDirectory|DirectoryService.H P:MasterCommander.Integrations.DirectoryService.MasterCommanderDirectory|DirectoryService.MasterCommanderDirectory.md|MasterCommanderDirectory P:MasterCommander.Integrations.DirectoryService.WorkingDirectory|DirectoryService.WorkingDirectory.md|WorkingDirectory M:MasterCommander.Integrations.DirectoryService.#ctor(MasterCommander.Core.Display.IConsole)|DirectoryService.DirectoryService(IConsole).md|DirectoryService(IConsole) +M:MasterCommander.Integrations.DirectoryService.SetWorkingDirectory(System.String)|DirectoryService.SetWorkingDirectory(string).md|SetWorkingDirectory(string) M:MasterCommander.Integrations.DirectoryService.SetWorkingDirectory(System.String,System.Boolean)|DirectoryService.SetWorkingDirectory(string,bool).md|SetWorkingDirectory(string, bool) +M:MasterCommander.Integrations.DirectoryService.CreateNewDirectory(System.String,System.String)|DirectoryService.CreateNewDirectory(string,string).md|CreateNewDirectory(string, string) M:MasterCommander.Integrations.DirectoryService.CreateNewDirectory(System.String,System.String,System.Boolean)|DirectoryService.CreateNewDirectory(string,string,bool).md|CreateNewDirectory(string, string, bool) M:MasterCommander.Integrations.DirectoryService.ClearDirectory(System.String)|DirectoryService.ClearDirectory(string).md|ClearDirectory(string) M:MasterCommander.Integrations.DirectoryService.CalculateDirectorySize(System.String)|DirectoryService.CalculateDirectorySize(string).md|CalculateDirectorySize(string) @@ -73,7 +75,9 @@ T:MasterCommander.Core.CmdOptionValuesAttribute|CmdOptionValuesAttribute.md|CmdO P:MasterCommander.Core.Services.IDirectoryService.HomeDirectory|IDirectoryService.HomeDirectory.md|HomeDirectory P:MasterCommander.Core.Services.IDirectoryService.MasterCommanderDirectory|IDirectoryService.MasterCommanderDirectory.md|MasterCommanderDirectory P:MasterCommander.Core.Services.IDirectoryService.WorkingDirectory|IDirectoryService.WorkingDirectory.md|WorkingDirectory +M:MasterCommander.Core.Services.IDirectoryService.SetWorkingDirectory(System.String)|IDirectoryService.SetWorkingDirectory(string).md|SetWorkingDirectory(string) M:MasterCommander.Core.Services.IDirectoryService.SetWorkingDirectory(System.String,System.Boolean)|IDirectoryService.SetWorkingDirectory(string,bool).md|SetWorkingDirectory(string, bool) +M:MasterCommander.Core.Services.IDirectoryService.CreateNewDirectory(System.String,System.String)|IDirectoryService.CreateNewDirectory(string,string).md|CreateNewDirectory(string, string) M:MasterCommander.Core.Services.IDirectoryService.CreateNewDirectory(System.String,System.String,System.Boolean)|IDirectoryService.CreateNewDirectory(string,string,bool).md|CreateNewDirectory(string, string, bool) M:MasterCommander.Core.Services.IDirectoryService.ClearDirectory(System.String)|IDirectoryService.ClearDirectory(string).md|ClearDirectory(string) M:MasterCommander.Core.Services.IDirectoryService.CalculateDirectorySize(System.String)|IDirectoryService.CalculateDirectorySize(string).md|CalculateDirectorySize(string) diff --git a/docs/master-commander/DirectoryService.CreateNewDirectory(string,string).md b/docs/master-commander/DirectoryService.CreateNewDirectory(string,string).md new file mode 100644 index 0000000..c523a33 --- /dev/null +++ b/docs/master-commander/DirectoryService.CreateNewDirectory(string,string).md @@ -0,0 +1,29 @@ +#### [MasterCommander](MasterCommander.md 'MasterCommander') +### [MasterCommander.Integrations](MasterCommander.md#MasterCommander.Integrations 'MasterCommander.Integrations').[DirectoryService](DirectoryService.md 'MasterCommander.Integrations.DirectoryService') + +## DirectoryService.CreateNewDirectory(string, string) Method + +Creates a new directory within a specified base directory. + +```csharp +public string CreateNewDirectory(string baseDirectory, string newDirectoryName); +``` +#### Parameters + + + +`baseDirectory` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String') + +The base directory where the new directory will be created. + + + +`newDirectoryName` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String') + +The name of the new directory to create. + +Implements [CreateNewDirectory(string, string)](IDirectoryService.CreateNewDirectory(string,string).md 'MasterCommander.Core.Services.IDirectoryService.CreateNewDirectory(string, string)') + +#### Returns +[System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String') +The path of the newly created directory. \ No newline at end of file diff --git a/docs/master-commander/DirectoryService.CreateNewDirectory(string,string,bool).md b/docs/master-commander/DirectoryService.CreateNewDirectory(string,string,bool).md index 44159da..1136297 100644 --- a/docs/master-commander/DirectoryService.CreateNewDirectory(string,string,bool).md +++ b/docs/master-commander/DirectoryService.CreateNewDirectory(string,string,bool).md @@ -6,7 +6,7 @@ Creates a new directory within a specified base directory. ```csharp -public string CreateNewDirectory(string baseDirectory, string newDirectoryName, bool overwrite=false); +public string CreateNewDirectory(string baseDirectory, string newDirectoryName, bool overwrite); ``` #### Parameters diff --git a/docs/master-commander/DirectoryService.SetWorkingDirectory(string).md b/docs/master-commander/DirectoryService.SetWorkingDirectory(string).md new file mode 100644 index 0000000..1489654 --- /dev/null +++ b/docs/master-commander/DirectoryService.SetWorkingDirectory(string).md @@ -0,0 +1,19 @@ +#### [MasterCommander](MasterCommander.md 'MasterCommander') +### [MasterCommander.Integrations](MasterCommander.md#MasterCommander.Integrations 'MasterCommander.Integrations').[DirectoryService](DirectoryService.md 'MasterCommander.Integrations.DirectoryService') + +## DirectoryService.SetWorkingDirectory(string) Method + +Sets the working directory to the directory where the specified solution is located. + +```csharp +public void SetWorkingDirectory(string relativePath); +``` +#### Parameters + + + +`relativePath` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String') + +The relative path from the MasterCommander directory to the solution directory. + +Implements [SetWorkingDirectory(string)](IDirectoryService.SetWorkingDirectory(string).md 'MasterCommander.Core.Services.IDirectoryService.SetWorkingDirectory(string)') \ No newline at end of file diff --git a/docs/master-commander/DirectoryService.SetWorkingDirectory(string,bool).md b/docs/master-commander/DirectoryService.SetWorkingDirectory(string,bool).md index 5194794..54370b0 100644 --- a/docs/master-commander/DirectoryService.SetWorkingDirectory(string,bool).md +++ b/docs/master-commander/DirectoryService.SetWorkingDirectory(string,bool).md @@ -6,7 +6,7 @@ Sets the working directory to the directory where the specified solution is located. ```csharp -public void SetWorkingDirectory(string relativePath, bool createIfNotExists=false); +public void SetWorkingDirectory(string relativePath, bool createIfNotExists); ``` #### Parameters diff --git a/docs/master-commander/DirectoryService.md b/docs/master-commander/DirectoryService.md index d8d043b..50439da 100644 --- a/docs/master-commander/DirectoryService.md +++ b/docs/master-commander/DirectoryService.md @@ -30,7 +30,9 @@ Implements [IDirectoryService](IDirectoryService.md 'MasterCommander.Core.Servic | [ClearDirectory(string)](DirectoryService.ClearDirectory(string).md 'MasterCommander.Integrations.DirectoryService.ClearDirectory(string)') | Clears the contents of a specified directory. | | [CompressDirectory(string, string)](DirectoryService.CompressDirectory(string,string).md 'MasterCommander.Integrations.DirectoryService.CompressDirectory(string, string)') | Compresses the specified directory into a ZIP file, including all its files and subdirectories. | | [CreateNewDirectory(string, string, bool)](DirectoryService.CreateNewDirectory(string,string,bool).md 'MasterCommander.Integrations.DirectoryService.CreateNewDirectory(string, string, bool)') | Creates a new directory within a specified base directory. | +| [CreateNewDirectory(string, string)](DirectoryService.CreateNewDirectory(string,string).md 'MasterCommander.Integrations.DirectoryService.CreateNewDirectory(string, string)') | Creates a new directory within a specified base directory. | | [CreateTemporaryDirectory()](DirectoryService.CreateTemporaryDirectory().md 'MasterCommander.Integrations.DirectoryService.CreateTemporaryDirectory()') | Creates a temporary directory for use during application execution, which can optionally be cleaned up afterwards. | | [DecompressToDirectory(string, string)](DirectoryService.DecompressToDirectory(string,string).md 'MasterCommander.Integrations.DirectoryService.DecompressToDirectory(string, string)') | Decompresses a ZIP file into a specified directory, extracting all its contents. | | [SetWorkingDirectory(string, bool)](DirectoryService.SetWorkingDirectory(string,bool).md 'MasterCommander.Integrations.DirectoryService.SetWorkingDirectory(string, bool)') | Sets the working directory to the directory where the specified solution is located. | +| [SetWorkingDirectory(string)](DirectoryService.SetWorkingDirectory(string).md 'MasterCommander.Integrations.DirectoryService.SetWorkingDirectory(string)') | Sets the working directory to the directory where the specified solution is located. | | [WatchDirectory(string, Action<FileSystemEventArgs>)](DirectoryService.WatchDirectory(string,Action_FileSystemEventArgs_).md 'MasterCommander.Integrations.DirectoryService.WatchDirectory(string, System.Action)') | Monitors a directory for any changes, such as file or subdirectory creation, deletion, or modification, and triggers a callback action when a change is detected. | diff --git a/docs/master-commander/IDirectoryService.CreateNewDirectory(string,string).md b/docs/master-commander/IDirectoryService.CreateNewDirectory(string,string).md new file mode 100644 index 0000000..105a196 --- /dev/null +++ b/docs/master-commander/IDirectoryService.CreateNewDirectory(string,string).md @@ -0,0 +1,27 @@ +#### [MasterCommander](MasterCommander.md 'MasterCommander') +### [MasterCommander.Core.Services](MasterCommander.md#MasterCommander.Core.Services 'MasterCommander.Core.Services').[IDirectoryService](IDirectoryService.md 'MasterCommander.Core.Services.IDirectoryService') + +## IDirectoryService.CreateNewDirectory(string, string) Method + +Creates a new directory within a specified base directory. + +```csharp +string CreateNewDirectory(string baseDirectory, string newDirectoryName); +``` +#### Parameters + + + +`baseDirectory` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String') + +The base directory where the new directory will be created. + + + +`newDirectoryName` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String') + +The name of the new directory to create. + +#### Returns +[System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String') +The path of the newly created directory. \ No newline at end of file diff --git a/docs/master-commander/IDirectoryService.CreateNewDirectory(string,string,bool).md b/docs/master-commander/IDirectoryService.CreateNewDirectory(string,string,bool).md index fe78d9e..b6c16eb 100644 --- a/docs/master-commander/IDirectoryService.CreateNewDirectory(string,string,bool).md +++ b/docs/master-commander/IDirectoryService.CreateNewDirectory(string,string,bool).md @@ -6,7 +6,7 @@ Creates a new directory within a specified base directory. ```csharp -string CreateNewDirectory(string baseDirectory, string newDirectoryName, bool overwrite=false); +string CreateNewDirectory(string baseDirectory, string newDirectoryName, bool overwrite); ``` #### Parameters diff --git a/docs/master-commander/IDirectoryService.SetWorkingDirectory(string).md b/docs/master-commander/IDirectoryService.SetWorkingDirectory(string).md new file mode 100644 index 0000000..1516a7f --- /dev/null +++ b/docs/master-commander/IDirectoryService.SetWorkingDirectory(string).md @@ -0,0 +1,17 @@ +#### [MasterCommander](MasterCommander.md 'MasterCommander') +### [MasterCommander.Core.Services](MasterCommander.md#MasterCommander.Core.Services 'MasterCommander.Core.Services').[IDirectoryService](IDirectoryService.md 'MasterCommander.Core.Services.IDirectoryService') + +## IDirectoryService.SetWorkingDirectory(string) Method + +Sets the working directory to the directory where the specified solution is located. + +```csharp +void SetWorkingDirectory(string relativePath); +``` +#### Parameters + + + +`relativePath` [System.String](https://docs.microsoft.com/en-us/dotnet/api/System.String 'System.String') + +The relative path from the MasterCommander directory to the solution directory. \ No newline at end of file diff --git a/docs/master-commander/IDirectoryService.SetWorkingDirectory(string,bool).md b/docs/master-commander/IDirectoryService.SetWorkingDirectory(string,bool).md index 1198259..8828bc6 100644 --- a/docs/master-commander/IDirectoryService.SetWorkingDirectory(string,bool).md +++ b/docs/master-commander/IDirectoryService.SetWorkingDirectory(string,bool).md @@ -6,7 +6,7 @@ Sets the working directory to the directory where the specified solution is located. ```csharp -void SetWorkingDirectory(string relativePath, bool createIfNotExists=false); +void SetWorkingDirectory(string relativePath, bool createIfNotExists); ``` #### Parameters diff --git a/docs/master-commander/IDirectoryService.md b/docs/master-commander/IDirectoryService.md index e862656..96a8d88 100644 --- a/docs/master-commander/IDirectoryService.md +++ b/docs/master-commander/IDirectoryService.md @@ -24,7 +24,9 @@ Derived | [ClearDirectory(string)](IDirectoryService.ClearDirectory(string).md 'MasterCommander.Core.Services.IDirectoryService.ClearDirectory(string)') | Clears the contents of a specified directory. | | [CompressDirectory(string, string)](IDirectoryService.CompressDirectory(string,string).md 'MasterCommander.Core.Services.IDirectoryService.CompressDirectory(string, string)') | Compresses the specified directory into a ZIP file, including all its files and subdirectories. | | [CreateNewDirectory(string, string, bool)](IDirectoryService.CreateNewDirectory(string,string,bool).md 'MasterCommander.Core.Services.IDirectoryService.CreateNewDirectory(string, string, bool)') | Creates a new directory within a specified base directory. | +| [CreateNewDirectory(string, string)](IDirectoryService.CreateNewDirectory(string,string).md 'MasterCommander.Core.Services.IDirectoryService.CreateNewDirectory(string, string)') | Creates a new directory within a specified base directory. | | [CreateTemporaryDirectory()](IDirectoryService.CreateTemporaryDirectory().md 'MasterCommander.Core.Services.IDirectoryService.CreateTemporaryDirectory()') | Creates a temporary directory for use during application execution, which can optionally be cleaned up afterwards. | | [DecompressToDirectory(string, string)](IDirectoryService.DecompressToDirectory(string,string).md 'MasterCommander.Core.Services.IDirectoryService.DecompressToDirectory(string, string)') | Decompresses a ZIP file into a specified directory, extracting all its contents. | | [SetWorkingDirectory(string, bool)](IDirectoryService.SetWorkingDirectory(string,bool).md 'MasterCommander.Core.Services.IDirectoryService.SetWorkingDirectory(string, bool)') | Sets the working directory to the directory where the specified solution is located. | +| [SetWorkingDirectory(string)](IDirectoryService.SetWorkingDirectory(string).md 'MasterCommander.Core.Services.IDirectoryService.SetWorkingDirectory(string)') | Sets the working directory to the directory where the specified solution is located. | | [WatchDirectory(string, Action<FileSystemEventArgs>)](IDirectoryService.WatchDirectory(string,Action_FileSystemEventArgs_).md 'MasterCommander.Core.Services.IDirectoryService.WatchDirectory(string, System.Action)') | Monitors a directory for any changes, such as file or subdirectory creation, deletion, or modification, and triggers a callback action when a change is detected. | diff --git a/src/library/MasterCommander/Core/Services/IDirectoryService.cs b/src/library/MasterCommander/Core/Services/IDirectoryService.cs index ed22718..b07a4b3 100644 --- a/src/library/MasterCommander/Core/Services/IDirectoryService.cs +++ b/src/library/MasterCommander/Core/Services/IDirectoryService.cs @@ -27,12 +27,26 @@ public interface IDirectoryService /// The working directory. string? WorkingDirectory { get; } + /// + /// Sets the working directory to the directory where the specified solution is located. + /// + /// The relative path from the MasterCommander directory to the solution directory. + void SetWorkingDirectory(string relativePath); + /// /// Sets the working directory to the directory where the specified solution is located. /// /// The relative path from the MasterCommander directory to the solution directory. /// A value indicating whether the directory should be created if it does not exist. - void SetWorkingDirectory(string relativePath, bool createIfNotExists = false); + void SetWorkingDirectory(string relativePath, bool createIfNotExists); + + /// + /// Creates a new directory within a specified base directory. + /// + /// The base directory where the new directory will be created. + /// The name of the new directory to create. + /// The path of the newly created directory. + string CreateNewDirectory(string baseDirectory, string newDirectoryName); /// /// Creates a new directory within a specified base directory. @@ -41,7 +55,7 @@ public interface IDirectoryService /// The name of the new directory to create. /// A value indicating whether an existing directory should be overwritten. /// The path of the newly created directory. - string CreateNewDirectory(string baseDirectory, string newDirectoryName, bool overwrite = false); + string CreateNewDirectory(string baseDirectory, string newDirectoryName, bool overwrite); /// /// Clears the contents of a specified directory. diff --git a/src/library/MasterCommander/Integrations/DirectoryService.cs b/src/library/MasterCommander/Integrations/DirectoryService.cs index aa6d2f7..bc03c90 100644 --- a/src/library/MasterCommander/Integrations/DirectoryService.cs +++ b/src/library/MasterCommander/Integrations/DirectoryService.cs @@ -44,7 +44,13 @@ public DirectoryService(IConsole console) public string? WorkingDirectory { get; set; } /// - public void SetWorkingDirectory(string relativePath, bool createIfNotExists = false) + public void SetWorkingDirectory(string relativePath) + { + WorkingDirectory = Path.Combine(MasterCommanderDirectory, relativePath); + } + + /// + public void SetWorkingDirectory(string relativePath, bool createIfNotExists) { WorkingDirectory = createIfNotExists ? CreateNewDirectory(MasterCommanderDirectory, relativePath, true) @@ -52,7 +58,7 @@ public void SetWorkingDirectory(string relativePath, bool createIfNotExists = fa } /// - public string CreateNewDirectory(string baseDirectory, string newDirectoryName, bool overwrite = false) + public string CreateNewDirectory(string baseDirectory, string newDirectoryName) { var newDirectory = Path.Combine(baseDirectory, newDirectoryName); @@ -60,7 +66,16 @@ public string CreateNewDirectory(string baseDirectory, string newDirectoryName, { Directory.CreateDirectory(newDirectory); } - else if (overwrite) + + return newDirectory; + } + + /// + public string CreateNewDirectory(string baseDirectory, string newDirectoryName, bool overwrite) + { + var newDirectory = CreateNewDirectory(baseDirectory, newDirectoryName); + + if (overwrite) { ClearDirectory(newDirectory); } @@ -112,10 +127,10 @@ public void WatchDirectory(string directoryPath, Action onC EnableRaisingEvents = true }; - watcher.Changed += (sender, e) => onChangeCallback(e); - watcher.Created += (sender, e) => onChangeCallback(e); - watcher.Deleted += (sender, e) => onChangeCallback(e); - watcher.Renamed += (sender, e) => onChangeCallback(e); + watcher.Changed += (_, e) => onChangeCallback(e); + watcher.Created += (_, e) => onChangeCallback(e); + watcher.Deleted += (_, e) => onChangeCallback(e); + watcher.Renamed += (_, e) => onChangeCallback(e); } ///