Browse Source

Ran format

Tim Jones 1 month ago
parent
commit
944edcefd0

+ 3 - 3
RackPeek.Domain/Persistence/IResourceCollection.cs

@@ -36,9 +36,9 @@ public interface IResourceCollection {
     Task<IReadOnlyList<Resource>> GetDependantsAsync(string name);
     Task<IReadOnlyList<Resource>> GetDependantsAsync(string name);
 
 
     Task Merge(string incomingYaml, MergeMode mode);
     Task Merge(string incomingYaml, MergeMode mode);
-    
-    
-    
+
+
+
     Task AddConnectionAsync(Connection connection);
     Task AddConnectionAsync(Connection connection);
     Task RemoveConnectionAsync(Connection connection);
     Task RemoveConnectionAsync(Connection connection);
     Task RemoveConnectionsForPortAsync(PortReference port);
     Task RemoveConnectionsForPortAsync(PortReference port);

+ 19 - 33
RackPeek.Domain/Persistence/Yaml/YamlResourceCollection.cs

@@ -194,7 +194,7 @@ public sealed class YamlResourceCollection(
 
 
         if (root.Resources != null)
         if (root.Resources != null)
             resourceCollection.Resources.AddRange(root.Resources);
             resourceCollection.Resources.AddRange(root.Resources);
-        
+
         resourceCollection.Connections.Clear();
         resourceCollection.Connections.Clear();
 
 
         if (root.Connections != null)
         if (root.Connections != null)
@@ -321,13 +321,13 @@ public sealed class YamlResourceCollection(
 
 
         // Preserve ordering: version first, then resources
         // Preserve ordering: version first, then resources
         Debug.Assert(root != null, nameof(root) + " != null");
         Debug.Assert(root != null, nameof(root) + " != null");
-        
+
         var payload = new OrderedDictionary {
         var payload = new OrderedDictionary {
             ["version"] = root.Version,
             ["version"] = root.Version,
             ["resources"] = (root.Resources ?? new List<Resource>()).Select(SerializeResource).ToList(),
             ["resources"] = (root.Resources ?? new List<Resource>()).Select(SerializeResource).ToList(),
             ["connections"] = root.Connections ?? new List<Connection>()
             ["connections"] = root.Connections ?? new List<Connection>()
         };
         };
-        
+
         await fileStore.WriteAllTextAsync(filePath, serializer.Serialize(payload));
         await fileStore.WriteAllTextAsync(filePath, serializer.Serialize(payload));
     }
     }
 
 
@@ -373,40 +373,32 @@ public sealed class YamlResourceCollection(
 
 
         return map;
         return map;
     }
     }
-    
-    private static bool PortsMatch(PortReference a, PortReference b)
-    {
+
+    private static bool PortsMatch(PortReference a, PortReference b) {
         return a.Resource.Equals(b.Resource, StringComparison.OrdinalIgnoreCase)
         return a.Resource.Equals(b.Resource, StringComparison.OrdinalIgnoreCase)
                && a.PortGroup == b.PortGroup
                && a.PortGroup == b.PortGroup
                && a.PortIndex == b.PortIndex;
                && a.PortIndex == b.PortIndex;
     }
     }
-    public Task AddConnectionAsync(Connection connection)
-    {
-        return UpdateConnectionsWithLockAsync(list =>
-        {
+    public Task AddConnectionAsync(Connection connection) {
+        return UpdateConnectionsWithLockAsync(list => {
             list.Add(connection);
             list.Add(connection);
         });
         });
     }
     }
-    public Task RemoveConnectionAsync(Connection connection)
-    {
-        return UpdateConnectionsWithLockAsync(list =>
-        {
+    public Task RemoveConnectionAsync(Connection connection) {
+        return UpdateConnectionsWithLockAsync(list => {
             list.RemoveAll(c =>
             list.RemoveAll(c =>
                 (PortsMatch(c.A, connection.A) && PortsMatch(c.B, connection.B)) ||
                 (PortsMatch(c.A, connection.A) && PortsMatch(c.B, connection.B)) ||
                 (PortsMatch(c.A, connection.B) && PortsMatch(c.B, connection.A)));
                 (PortsMatch(c.A, connection.B) && PortsMatch(c.B, connection.A)));
         });
         });
     }
     }
-    public Task RemoveConnectionsForPortAsync(PortReference port)
-    {
-        return UpdateConnectionsWithLockAsync(list =>
-        {
+    public Task RemoveConnectionsForPortAsync(PortReference port) {
+        return UpdateConnectionsWithLockAsync(list => {
             list.RemoveAll(c =>
             list.RemoveAll(c =>
                 PortsMatch(c.A, port) ||
                 PortsMatch(c.A, port) ||
                 PortsMatch(c.B, port));
                 PortsMatch(c.B, port));
         });
         });
     }
     }
-    public Task<IReadOnlyList<Connection>> GetConnectionsAsync()
-    {
+    public Task<IReadOnlyList<Connection>> GetConnectionsAsync() {
         IReadOnlyList<Connection> result =
         IReadOnlyList<Connection> result =
             resourceCollection.Connections
             resourceCollection.Connections
                 .ToList()
                 .ToList()
@@ -414,8 +406,7 @@ public sealed class YamlResourceCollection(
 
 
         return Task.FromResult(result);
         return Task.FromResult(result);
     }
     }
-    public Task<IReadOnlyList<Connection>> GetConnectionsForResourceAsync(string resource)
-    {
+    public Task<IReadOnlyList<Connection>> GetConnectionsForResourceAsync(string resource) {
         IReadOnlyList<Connection> result =
         IReadOnlyList<Connection> result =
             resourceCollection.Connections
             resourceCollection.Connections
                 .Where(c =>
                 .Where(c =>
@@ -426,8 +417,7 @@ public sealed class YamlResourceCollection(
 
 
         return Task.FromResult(result);
         return Task.FromResult(result);
     }
     }
-    public Task<Connection?> GetConnectionForPortAsync(PortReference port)
-    {
+    public Task<Connection?> GetConnectionForPortAsync(PortReference port) {
         Connection? connection =
         Connection? connection =
             resourceCollection.Connections
             resourceCollection.Connections
                 .FirstOrDefault(c =>
                 .FirstOrDefault(c =>
@@ -436,15 +426,12 @@ public sealed class YamlResourceCollection(
 
 
         return Task.FromResult(connection);
         return Task.FromResult(connection);
     }
     }
-    private async Task UpdateConnectionsWithLockAsync(Action<List<Connection>> action)
-    {
+    private async Task UpdateConnectionsWithLockAsync(Action<List<Connection>> action) {
         await resourceCollection.FileLock.WaitAsync();
         await resourceCollection.FileLock.WaitAsync();
-        try
-        {
+        try {
             action(resourceCollection.Connections);
             action(resourceCollection.Connections);
 
 
-            var root = new YamlRoot
-            {
+            var root = new YamlRoot {
                 Version = _currentSchemaVersion,
                 Version = _currentSchemaVersion,
                 Resources = resourceCollection.Resources,
                 Resources = resourceCollection.Resources,
                 Connections = resourceCollection.Connections
                 Connections = resourceCollection.Connections
@@ -452,8 +439,7 @@ public sealed class YamlResourceCollection(
 
 
             await SaveRootAsync(root);
             await SaveRootAsync(root);
         }
         }
-        finally
-        {
+        finally {
             resourceCollection.FileLock.Release();
             resourceCollection.FileLock.Release();
         }
         }
     }
     }
@@ -462,6 +448,6 @@ public sealed class YamlResourceCollection(
 public class YamlRoot {
 public class YamlRoot {
     public int Version { get; set; }
     public int Version { get; set; }
     public List<Resource>? Resources { get; set; }
     public List<Resource>? Resources { get; set; }
-    
+
     public List<Connection>? Connections { get; set; }
     public List<Connection>? Connections { get; set; }
 }
 }

+ 6 - 12
RackPeek.Domain/Resources/Connections/AddConnectionUseCase.cs

@@ -5,8 +5,7 @@ using RackPeek.Domain.Resources.SubResources;
 
 
 namespace RackPeek.Domain.Resources.Connections;
 namespace RackPeek.Domain.Resources.Connections;
 
 
-public interface IAddConnectionUseCase
-{
+public interface IAddConnectionUseCase {
     Task ExecuteAsync(
     Task ExecuteAsync(
         PortReference a,
         PortReference a,
         PortReference b,
         PortReference b,
@@ -15,14 +14,12 @@ public interface IAddConnectionUseCase
 }
 }
 
 
 public class AddConnectionUseCase(IResourceCollection repository)
 public class AddConnectionUseCase(IResourceCollection repository)
-    : IAddConnectionUseCase
-{
+    : IAddConnectionUseCase {
     public async Task ExecuteAsync(
     public async Task ExecuteAsync(
         PortReference a,
         PortReference a,
         PortReference b,
         PortReference b,
         string? label,
         string? label,
-        string? notes)
-    {
+        string? notes) {
         a.Resource = Normalize.HardwareName(a.Resource);
         a.Resource = Normalize.HardwareName(a.Resource);
         b.Resource = Normalize.HardwareName(b.Resource);
         b.Resource = Normalize.HardwareName(b.Resource);
 
 
@@ -42,8 +39,7 @@ public class AddConnectionUseCase(IResourceCollection repository)
         await repository.RemoveConnectionsForPortAsync(a);
         await repository.RemoveConnectionsForPortAsync(a);
         await repository.RemoveConnectionsForPortAsync(b);
         await repository.RemoveConnectionsForPortAsync(b);
 
 
-        var connection = new Connection
-        {
+        var connection = new Connection {
             A = a,
             A = a,
             B = b,
             B = b,
             Label = label,
             Label = label,
@@ -53,8 +49,7 @@ public class AddConnectionUseCase(IResourceCollection repository)
         await repository.AddConnectionAsync(connection);
         await repository.AddConnectionAsync(connection);
     }
     }
 
 
-    private async Task ValidatePortReference(PortReference port)
-    {
+    private async Task ValidatePortReference(PortReference port) {
         Resource resource =
         Resource resource =
             await repository.GetByNameAsync<Resource>(port.Resource)
             await repository.GetByNameAsync<Resource>(port.Resource)
             ?? throw new NotFoundException($"Resource '{port.Resource}' not found.");
             ?? throw new NotFoundException($"Resource '{port.Resource}' not found.");
@@ -71,8 +66,7 @@ public class AddConnectionUseCase(IResourceCollection repository)
             throw new NotFoundException($"Port index {port.PortIndex} not found.");
             throw new NotFoundException($"Port index {port.PortIndex} not found.");
     }
     }
 
 
-    private static bool PortsMatch(PortReference a, PortReference b)
-    {
+    private static bool PortsMatch(PortReference a, PortReference b) {
         return a.Resource.Equals(b.Resource, StringComparison.OrdinalIgnoreCase)
         return a.Resource.Equals(b.Resource, StringComparison.OrdinalIgnoreCase)
                && a.PortGroup == b.PortGroup
                && a.PortGroup == b.PortGroup
                && a.PortIndex == b.PortIndex;
                && a.PortIndex == b.PortIndex;

+ 2 - 4
RackPeek.Domain/Resources/Connections/Connection.cs

@@ -1,7 +1,6 @@
 namespace RackPeek.Domain.Resources.Connections;
 namespace RackPeek.Domain.Resources.Connections;
 
 
-public class Connection
-{
+public class Connection {
     public PortReference A { get; set; } = null!;
     public PortReference A { get; set; } = null!;
 
 
     public PortReference B { get; set; } = null!;
     public PortReference B { get; set; } = null!;
@@ -11,8 +10,7 @@ public class Connection
     public string? Notes { get; set; }
     public string? Notes { get; set; }
 }
 }
 
 
-public class PortReference
-{
+public class PortReference {
     public string Resource { get; set; } = null!;
     public string Resource { get; set; } = null!;
     public int PortGroup { get; set; }
     public int PortGroup { get; set; }
     public int PortIndex { get; set; }
     public int PortIndex { get; set; }

+ 2 - 4
RackPeek.Domain/Resources/Connections/ConnectionHelpers.cs

@@ -1,9 +1,7 @@
 namespace RackPeek.Domain.Resources.Connections;
 namespace RackPeek.Domain.Resources.Connections;
 
 
-public static class ConnectionHelpers
-{
-    public static bool Matches(PortReference a, PortReference b)
-    {
+public static class ConnectionHelpers {
+    public static bool Matches(PortReference a, PortReference b) {
         return a.Resource == b.Resource
         return a.Resource == b.Resource
                && a.PortGroup == b.PortGroup
                && a.PortGroup == b.PortGroup
                && a.PortIndex == b.PortIndex;
                && a.PortIndex == b.PortIndex;

+ 4 - 7
RackPeek.Domain/Resources/Connections/GetConnectionForPortUseCase.cs

@@ -3,20 +3,17 @@ using RackPeek.Domain.Persistence;
 
 
 namespace RackPeek.Domain.Resources.Connections;
 namespace RackPeek.Domain.Resources.Connections;
 
 
-public interface IGetConnectionForPortUseCase
-{
+public interface IGetConnectionForPortUseCase {
     Task<Connection?> ExecuteAsync(PortReference port);
     Task<Connection?> ExecuteAsync(PortReference port);
 }
 }
 
 
 public class GetConnectionForPortUseCase(IResourceCollection repository)
 public class GetConnectionForPortUseCase(IResourceCollection repository)
-    : IGetConnectionForPortUseCase
-{
-    public async Task<Connection?> ExecuteAsync(PortReference port)
-    {
+    : IGetConnectionForPortUseCase {
+    public async Task<Connection?> ExecuteAsync(PortReference port) {
         port.Resource = Normalize.HardwareName(port.Resource);
         port.Resource = Normalize.HardwareName(port.Resource);
 
 
         ThrowIfInvalid.ResourceName(port.Resource);
         ThrowIfInvalid.ResourceName(port.Resource);
 
 
         return await repository.GetConnectionForPortAsync(port);
         return await repository.GetConnectionForPortAsync(port);
     }
     }
-}
+}

+ 4 - 7
RackPeek.Domain/Resources/Connections/GetConnectionsForResourceUseCase.cs

@@ -3,20 +3,17 @@ using RackPeek.Domain.Persistence;
 
 
 namespace RackPeek.Domain.Resources.Connections;
 namespace RackPeek.Domain.Resources.Connections;
 
 
-public interface IGetConnectionsForResourceUseCase
-{
+public interface IGetConnectionsForResourceUseCase {
     Task<IReadOnlyList<Connection>> ExecuteAsync(string resource);
     Task<IReadOnlyList<Connection>> ExecuteAsync(string resource);
 }
 }
 
 
 public class GetConnectionsForResourceUseCase(IResourceCollection repository)
 public class GetConnectionsForResourceUseCase(IResourceCollection repository)
-    : IGetConnectionsForResourceUseCase
-{
-    public async Task<IReadOnlyList<Connection>> ExecuteAsync(string resource)
-    {
+    : IGetConnectionsForResourceUseCase {
+    public async Task<IReadOnlyList<Connection>> ExecuteAsync(string resource) {
         resource = Normalize.HardwareName(resource);
         resource = Normalize.HardwareName(resource);
 
 
         ThrowIfInvalid.ResourceName(resource);
         ThrowIfInvalid.ResourceName(resource);
 
 
         return await repository.GetConnectionsForResourceAsync(resource);
         return await repository.GetConnectionsForResourceAsync(resource);
     }
     }
-}
+}

+ 4 - 7
RackPeek.Domain/Resources/Connections/RemoveConnectionUseCase.cs

@@ -3,20 +3,17 @@ using RackPeek.Domain.Persistence;
 
 
 namespace RackPeek.Domain.Resources.Connections;
 namespace RackPeek.Domain.Resources.Connections;
 
 
-public interface IRemoveConnectionUseCase
-{
+public interface IRemoveConnectionUseCase {
     Task ExecuteAsync(PortReference port);
     Task ExecuteAsync(PortReference port);
 }
 }
 
 
 public class RemoveConnectionUseCase(IResourceCollection repository)
 public class RemoveConnectionUseCase(IResourceCollection repository)
-    : IRemoveConnectionUseCase
-{
-    public async Task ExecuteAsync(PortReference port)
-    {
+    : IRemoveConnectionUseCase {
+    public async Task ExecuteAsync(PortReference port) {
         port.Resource = Normalize.HardwareName(port.Resource);
         port.Resource = Normalize.HardwareName(port.Resource);
 
 
         ThrowIfInvalid.ResourceName(port.Resource);
         ThrowIfInvalid.ResourceName(port.Resource);
 
 
         await repository.RemoveConnectionsForPortAsync(port);
         await repository.RemoveConnectionsForPortAsync(port);
     }
     }
-}
+}

+ 1 - 1
RackPeek.Domain/ServiceCollectionExtensions.cs

@@ -76,7 +76,7 @@ public static class ServiceCollectionExtensions {
         services.AddScoped(typeof(IGetConnectionsForResourceUseCase), typeof(GetConnectionsForResourceUseCase));
         services.AddScoped(typeof(IGetConnectionsForResourceUseCase), typeof(GetConnectionsForResourceUseCase));
         services.AddScoped(typeof(IRemoveConnectionUseCase), typeof(RemoveConnectionUseCase));
         services.AddScoped(typeof(IRemoveConnectionUseCase), typeof(RemoveConnectionUseCase));
 
 
-        
+
         IEnumerable<Type>? usecases = Assembly.GetAssembly(typeof(IUseCase))
         IEnumerable<Type>? usecases = Assembly.GetAssembly(typeof(IUseCase))
             ?.GetTypes()
             ?.GetTypes()
             .Where(t =>
             .Where(t =>

+ 14 - 28
RackPeek.Domain/UseCases/Ports/RemovePortUseCase.cs

@@ -8,16 +8,13 @@ using RackPeek.Domain.Resources.SubResources;
 namespace RackPeek.Domain.UseCases.Ports;
 namespace RackPeek.Domain.UseCases.Ports;
 
 
 public interface IRemovePortUseCase<T> : IResourceUseCase<T>
 public interface IRemovePortUseCase<T> : IResourceUseCase<T>
-    where T : Resource
-{
+    where T : Resource {
     Task ExecuteAsync(string name, int index);
     Task ExecuteAsync(string name, int index);
 }
 }
 
 
 public class RemovePortUseCase<T>(IResourceCollection repository)
 public class RemovePortUseCase<T>(IResourceCollection repository)
-    : IRemovePortUseCase<T> where T : Resource
-{
-    public async Task ExecuteAsync(string name, int index)
-    {
+    : IRemovePortUseCase<T> where T : Resource {
+    public async Task ExecuteAsync(string name, int index) {
         name = Normalize.HardwareName(name);
         name = Normalize.HardwareName(name);
         ThrowIfInvalid.ResourceName(name);
         ThrowIfInvalid.ResourceName(name);
 
 
@@ -36,26 +33,21 @@ public class RemovePortUseCase<T>(IResourceCollection repository)
         var toRemove = new List<Connection>();
         var toRemove = new List<Connection>();
         var toAdd = new List<Connection>();
         var toAdd = new List<Connection>();
 
 
-        foreach (Connection connection in connections)
-        {
+        foreach (Connection connection in connections) {
             var changed = false;
             var changed = false;
 
 
             PortReference a = connection.A;
             PortReference a = connection.A;
             PortReference b = connection.B;
             PortReference b = connection.B;
 
 
             // handle A side
             // handle A side
-            if (a.Resource.Equals(name, StringComparison.OrdinalIgnoreCase))
-            {
-                if (a.PortGroup == index)
-                {
+            if (a.Resource.Equals(name, StringComparison.OrdinalIgnoreCase)) {
+                if (a.PortGroup == index) {
                     toRemove.Add(connection);
                     toRemove.Add(connection);
                     continue;
                     continue;
                 }
                 }
 
 
-                if (a.PortGroup > index)
-                {
-                    a = new PortReference
-                    {
+                if (a.PortGroup > index) {
+                    a = new PortReference {
                         Resource = a.Resource,
                         Resource = a.Resource,
                         PortGroup = a.PortGroup - 1,
                         PortGroup = a.PortGroup - 1,
                         PortIndex = a.PortIndex
                         PortIndex = a.PortIndex
@@ -66,18 +58,14 @@ public class RemovePortUseCase<T>(IResourceCollection repository)
             }
             }
 
 
             // handle B side
             // handle B side
-            if (b.Resource.Equals(name, StringComparison.OrdinalIgnoreCase))
-            {
-                if (b.PortGroup == index)
-                {
+            if (b.Resource.Equals(name, StringComparison.OrdinalIgnoreCase)) {
+                if (b.PortGroup == index) {
                     toRemove.Add(connection);
                     toRemove.Add(connection);
                     continue;
                     continue;
                 }
                 }
 
 
-                if (b.PortGroup > index)
-                {
-                    b = new PortReference
-                    {
+                if (b.PortGroup > index) {
+                    b = new PortReference {
                         Resource = b.Resource,
                         Resource = b.Resource,
                         PortGroup = b.PortGroup - 1,
                         PortGroup = b.PortGroup - 1,
                         PortIndex = b.PortIndex
                         PortIndex = b.PortIndex
@@ -87,12 +75,10 @@ public class RemovePortUseCase<T>(IResourceCollection repository)
                 }
                 }
             }
             }
 
 
-            if (changed)
-            {
+            if (changed) {
                 toRemove.Add(connection);
                 toRemove.Add(connection);
 
 
-                toAdd.Add(new Connection
-                {
+                toAdd.Add(new Connection {
                     A = a,
                     A = a,
                     B = b,
                     B = b,
                     Label = connection.Label,
                     Label = connection.Label,

+ 3 - 6
RackPeek.Domain/UseCases/Ports/UpdatePortUseCase.cs

@@ -46,12 +46,9 @@ public class UpdatePortUseCase<T>(IResourceCollection repository) : IUpdatePortU
         var oldCount = nic.Count ?? 0;
         var oldCount = nic.Count ?? 0;
         var newCount = ports ?? oldCount;
         var newCount = ports ?? oldCount;
 
 
-        if (newCount < oldCount)
-        {
-            for (var i = newCount; i < oldCount; i++)
-            {
-                await repository.RemoveConnectionsForPortAsync(new PortReference
-                {
+        if (newCount < oldCount) {
+            for (var i = newCount; i < oldCount; i++) {
+                await repository.RemoveConnectionsForPortAsync(new PortReference {
                     Resource = name,
                     Resource = name,
                     PortGroup = index,
                     PortGroup = index,
                     PortIndex = i
                     PortIndex = i

+ 1 - 1
RackPeek.Domain/UseCases/SSH/SshConfigExportUseCase.cs

@@ -1,7 +1,7 @@
 using RackPeek.Domain.Persistence;
 using RackPeek.Domain.Persistence;
 using RackPeek.Domain.Resources;
 using RackPeek.Domain.Resources;
 
 
-namespace RackPeek.Domain.UseCases.Ssh;
+namespace RackPeek.Domain.UseCases.SSH;
 
 
 public class SshConfigExportUseCase(IResourceCollection repository) : IUseCase {
 public class SshConfigExportUseCase(IResourceCollection repository) : IUseCase {
     public async Task<SshExportResult?> ExecuteAsync(SshExportOptions options) {
     public async Task<SshExportResult?> ExecuteAsync(SshExportOptions options) {

+ 1 - 1
RackPeek.Domain/UseCases/SSH/SshConfigGenerator.cs

@@ -1,7 +1,7 @@
 using System.Text;
 using System.Text;
 using RackPeek.Domain.Resources;
 using RackPeek.Domain.Resources;
 
 
-namespace RackPeek.Domain.UseCases.Ssh;
+namespace RackPeek.Domain.UseCases.SSH;
 
 
 public static class SshConfigGenerator {
 public static class SshConfigGenerator {
     public static SshExportResult ToSshConfig(
     public static SshExportResult ToSshConfig(

+ 1 - 1
RackPeek.Domain/UseCases/SSH/SshExportOptions.cs

@@ -1,4 +1,4 @@
-namespace RackPeek.Domain.UseCases.Ssh;
+namespace RackPeek.Domain.UseCases.SSH;
 
 
 public sealed record SshExportOptions {
 public sealed record SshExportOptions {
     /// <summary>
     /// <summary>

+ 2 - 3
Shared.Rcl/CliBootstrap.cs

@@ -578,9 +578,8 @@ public static class CliBootstrap {
                 hosts.AddCommand<GenerateHostsFileCommand>("export")
                 hosts.AddCommand<GenerateHostsFileCommand>("export")
                     .WithDescription("Generate a /etc/hosts compatible file.");
                     .WithDescription("Generate a /etc/hosts compatible file.");
             });
             });
-            
-            config.AddBranch("connections", connections =>
-            {
+
+            config.AddBranch("connections", connections => {
                 connections.SetDescription("Manage physical or logical port connections.");
                 connections.SetDescription("Manage physical or logical port connections.");
 
 
                 connections.AddCommand<ConnectionAddCommand>("add")
                 connections.AddCommand<ConnectionAddCommand>("add")

+ 5 - 10
Shared.Rcl/Commands/Connections/ConnectionAddCommand.cs

@@ -6,8 +6,7 @@ using Spectre.Console.Cli;
 
 
 namespace Shared.Rcl.Commands.Connections;
 namespace Shared.Rcl.Commands.Connections;
 
 
-public class ConnectionAddSettings : CommandSettings
-{
+public class ConnectionAddSettings : CommandSettings {
     [CommandArgument(0, "<A_RESOURCE>")]
     [CommandArgument(0, "<A_RESOURCE>")]
     [Description("Resource name for endpoint A.")]
     [Description("Resource name for endpoint A.")]
     public string AResource { get; set; } = null!;
     public string AResource { get; set; } = null!;
@@ -43,27 +42,23 @@ public class ConnectionAddSettings : CommandSettings
 
 
 public class ConnectionAddCommand(
 public class ConnectionAddCommand(
     IServiceProvider serviceProvider
     IServiceProvider serviceProvider
-) : AsyncCommand<ConnectionAddSettings>
-{
+) : AsyncCommand<ConnectionAddSettings> {
     public override async Task<int> ExecuteAsync(
     public override async Task<int> ExecuteAsync(
         CommandContext context,
         CommandContext context,
         ConnectionAddSettings settings,
         ConnectionAddSettings settings,
-        CancellationToken cancellationToken)
-    {
+        CancellationToken cancellationToken) {
         using IServiceScope scope = serviceProvider.CreateScope();
         using IServiceScope scope = serviceProvider.CreateScope();
 
 
         IAddConnectionUseCase useCase =
         IAddConnectionUseCase useCase =
             scope.ServiceProvider.GetRequiredService<IAddConnectionUseCase>();
             scope.ServiceProvider.GetRequiredService<IAddConnectionUseCase>();
 
 
-        var a = new PortReference
-        {
+        var a = new PortReference {
             Resource = settings.AResource,
             Resource = settings.AResource,
             PortGroup = settings.AGroup,
             PortGroup = settings.AGroup,
             PortIndex = settings.AIndex
             PortIndex = settings.AIndex
         };
         };
 
 
-        var b = new PortReference
-        {
+        var b = new PortReference {
             Resource = settings.BResource,
             Resource = settings.BResource,
             PortGroup = settings.BGroup,
             PortGroup = settings.BGroup,
             PortIndex = settings.BIndex
             PortIndex = settings.BIndex

+ 4 - 8
Shared.Rcl/Commands/Connections/ConnectionRemoveCommand.cs

@@ -7,8 +7,7 @@ using Spectre.Console.Cli;
 
 
 namespace Shared.Rcl.Commands.Connections;
 namespace Shared.Rcl.Commands.Connections;
 
 
-public class ConnectionRemoveSettings : CommandSettings
-{
+public class ConnectionRemoveSettings : CommandSettings {
     [CommandArgument(0, "<RESOURCE>")]
     [CommandArgument(0, "<RESOURCE>")]
     [Description("Resource name.")]
     [Description("Resource name.")]
     public string Resource { get; set; } = null!;
     public string Resource { get; set; } = null!;
@@ -24,20 +23,17 @@ public class ConnectionRemoveSettings : CommandSettings
 
 
 public class ConnectionRemoveCommand(
 public class ConnectionRemoveCommand(
     IServiceProvider serviceProvider
     IServiceProvider serviceProvider
-) : AsyncCommand<ConnectionRemoveSettings>
-{
+) : AsyncCommand<ConnectionRemoveSettings> {
     public override async Task<int> ExecuteAsync(
     public override async Task<int> ExecuteAsync(
         CommandContext context,
         CommandContext context,
         ConnectionRemoveSettings settings,
         ConnectionRemoveSettings settings,
-        CancellationToken cancellationToken)
-    {
+        CancellationToken cancellationToken) {
         using IServiceScope scope = serviceProvider.CreateScope();
         using IServiceScope scope = serviceProvider.CreateScope();
 
 
         IRemoveConnectionUseCase useCase =
         IRemoveConnectionUseCase useCase =
             scope.ServiceProvider.GetRequiredService<IRemoveConnectionUseCase>();
             scope.ServiceProvider.GetRequiredService<IRemoveConnectionUseCase>();
 
 
-        var port = new PortReference
-        {
+        var port = new PortReference {
             Resource = settings.Resource,
             Resource = settings.Resource,
             PortGroup = settings.PortGroup,
             PortGroup = settings.PortGroup,
             PortIndex = settings.PortIndex
             PortIndex = settings.PortIndex

+ 1 - 1
Shared.Rcl/Commands/Exporters/GenerateSshConfigCommand.cs

@@ -1,5 +1,5 @@
 using Microsoft.Extensions.DependencyInjection;
 using Microsoft.Extensions.DependencyInjection;
-using RackPeek.Domain.UseCases.Ssh;
+using RackPeek.Domain.UseCases.SSH;
 using Spectre.Console;
 using Spectre.Console;
 using Spectre.Console.Cli;
 using Spectre.Console.Cli;
 
 

+ 1 - 1
Shared.Rcl/Components/SshExport.razor

@@ -1,5 +1,5 @@
 @page "/ssh/export"
 @page "/ssh/export"
-@using RackPeek.Domain.UseCases.Ssh
+@using RackPeek.Domain.UseCases.SSH
 @inject SshConfigExportUseCase SshUseCase
 @inject SshConfigExportUseCase SshUseCase
 
 
 <div class="border border-zinc-800 rounded p-4 bg-zinc-900 max-w-5xl mx-auto"
 <div class="border border-zinc-800 rounded p-4 bg-zinc-900 max-w-5xl mx-auto"

+ 5 - 10
Tests/EndToEnd/ConnectionTests/ConnectionRemoveWorkflowTests.cs

@@ -5,10 +5,8 @@ namespace Tests.EndToEnd.ConnectionTests;
 
 
 [Collection("Yaml CLI tests")]
 [Collection("Yaml CLI tests")]
 public class ConnectionRemoveWorkflowTests(TempYamlCliFixture fs, ITestOutputHelper outputHelper)
 public class ConnectionRemoveWorkflowTests(TempYamlCliFixture fs, ITestOutputHelper outputHelper)
-    : IClassFixture<TempYamlCliFixture>
-{
-    private async Task<(string output, string yaml)> ExecuteAsync(params string[] args)
-    {
+    : IClassFixture<TempYamlCliFixture> {
+    private async Task<(string output, string yaml)> ExecuteAsync(params string[] args) {
         outputHelper.WriteLine($"rpk {string.Join(" ", args)}");
         outputHelper.WriteLine($"rpk {string.Join(" ", args)}");
 
 
         var output = await YamlCliTestHost.RunAsync(
         var output = await YamlCliTestHost.RunAsync(
@@ -26,8 +24,7 @@ public class ConnectionRemoveWorkflowTests(TempYamlCliFixture fs, ITestOutputHel
     [Theory]
     [Theory]
     [InlineData("switches", "routers")]
     [InlineData("switches", "routers")]
     [InlineData("firewalls", "routers")]
     [InlineData("firewalls", "routers")]
-    public async Task connections_remove_cli_workflow_test(string aType, string bType)
-    {
+    public async Task connections_remove_cli_workflow_test(string aType, string bType) {
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
 
 
         // Create resources
         // Create resources
@@ -70,8 +67,7 @@ public class ConnectionRemoveWorkflowTests(TempYamlCliFixture fs, ITestOutputHel
     }
     }
 
 
     [Fact]
     [Fact]
-    public async Task removing_connection_from_other_endpoint_works()
-    {
+    public async Task removing_connection_from_other_endpoint_works() {
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
 
 
         await ExecuteAsync("servers", "add", "srv01");
         await ExecuteAsync("servers", "add", "srv01");
@@ -110,8 +106,7 @@ public class ConnectionRemoveWorkflowTests(TempYamlCliFixture fs, ITestOutputHel
     }
     }
 
 
     [Fact]
     [Fact]
-    public async Task removing_nonexistent_connection_is_safe()
-    {
+    public async Task removing_nonexistent_connection_is_safe() {
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
 
 
         await ExecuteAsync("switches", "add", "sw01");
         await ExecuteAsync("switches", "add", "sw01");

+ 5 - 10
Tests/EndToEnd/ConnectionTests/ConnectionWorkflowTests.cs

@@ -5,10 +5,8 @@ namespace Tests.EndToEnd.ConnectionTests;
 
 
 [Collection("Yaml CLI tests")]
 [Collection("Yaml CLI tests")]
 public class ConnectionWorkflowTests(TempYamlCliFixture fs, ITestOutputHelper outputHelper)
 public class ConnectionWorkflowTests(TempYamlCliFixture fs, ITestOutputHelper outputHelper)
-    : IClassFixture<TempYamlCliFixture>
-{
-    private async Task<(string output, string yaml)> ExecuteAsync(params string[] args)
-    {
+    : IClassFixture<TempYamlCliFixture> {
+    private async Task<(string output, string yaml)> ExecuteAsync(params string[] args) {
         outputHelper.WriteLine($"rpk {string.Join(" ", args)}");
         outputHelper.WriteLine($"rpk {string.Join(" ", args)}");
 
 
         var output = await YamlCliTestHost.RunAsync(
         var output = await YamlCliTestHost.RunAsync(
@@ -27,8 +25,7 @@ public class ConnectionWorkflowTests(TempYamlCliFixture fs, ITestOutputHelper ou
     [InlineData("switches", "routers")]
     [InlineData("switches", "routers")]
     [InlineData("firewalls", "routers")]
     [InlineData("firewalls", "routers")]
 
 
-    public async Task connections_cli_workflow_test(string aType, string bType)
-    {
+    public async Task connections_cli_workflow_test(string aType, string bType) {
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
 
 
         // Create resources
         // Create resources
@@ -69,8 +66,7 @@ public class ConnectionWorkflowTests(TempYamlCliFixture fs, ITestOutputHelper ou
     }
     }
 
 
     [Fact]
     [Fact]
-    public async Task connections_overwrite_existing_port_connection()
-    {
+    public async Task connections_overwrite_existing_port_connection() {
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
 
 
         await ExecuteAsync("servers", "add", "srv01");
         await ExecuteAsync("servers", "add", "srv01");
@@ -122,8 +118,7 @@ public class ConnectionWorkflowTests(TempYamlCliFixture fs, ITestOutputHelper ou
     }
     }
 
 
     [Fact]
     [Fact]
-    public async Task connections_cannot_connect_port_to_itself()
-    {
+    public async Task connections_cannot_connect_port_to_itself() {
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
 
 
         await ExecuteAsync("servers", "add", "srv01");
         await ExecuteAsync("servers", "add", "srv01");

+ 6 - 12
Tests/EndToEnd/ConnectionTests/PortConnectionWorkflowTests.cs

@@ -5,10 +5,8 @@ namespace Tests.EndToEnd.ConnectionTests;
 
 
 [Collection("Yaml CLI tests")]
 [Collection("Yaml CLI tests")]
 public class PortConnectionWorkflowTests(TempYamlCliFixture fs, ITestOutputHelper outputHelper)
 public class PortConnectionWorkflowTests(TempYamlCliFixture fs, ITestOutputHelper outputHelper)
-    : IClassFixture<TempYamlCliFixture>
-{
-    private async Task<(string output, string yaml)> ExecuteAsync(params string[] args)
-    {
+    : IClassFixture<TempYamlCliFixture> {
+    private async Task<(string output, string yaml)> ExecuteAsync(params string[] args) {
         outputHelper.WriteLine($"rpk {string.Join(" ", args)}");
         outputHelper.WriteLine($"rpk {string.Join(" ", args)}");
 
 
         var output = await YamlCliTestHost.RunAsync(
         var output = await YamlCliTestHost.RunAsync(
@@ -26,8 +24,7 @@ public class PortConnectionWorkflowTests(TempYamlCliFixture fs, ITestOutputHelpe
     [Theory]
     [Theory]
     [InlineData("switches", "routers")]
     [InlineData("switches", "routers")]
     [InlineData("firewalls", "routers")]
     [InlineData("firewalls", "routers")]
-    public async Task removing_port_removes_connections(string aType, string bType)
-    {
+    public async Task removing_port_removes_connections(string aType, string bType) {
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
 
 
         await ExecuteAsync(aType, "add", "node-a");
         await ExecuteAsync(aType, "add", "node-a");
@@ -59,8 +56,7 @@ public class PortConnectionWorkflowTests(TempYamlCliFixture fs, ITestOutputHelpe
     [Theory]
     [Theory]
     [InlineData("switches", "routers")]
     [InlineData("switches", "routers")]
     [InlineData("firewalls", "routers")]
     [InlineData("firewalls", "routers")]
-    public async Task removing_port_shifts_connection_groups(string aType, string bType)
-    {
+    public async Task removing_port_shifts_connection_groups(string aType, string bType) {
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
 
 
         await ExecuteAsync(aType, "add", "node-a");
         await ExecuteAsync(aType, "add", "node-a");
@@ -101,8 +97,7 @@ public class PortConnectionWorkflowTests(TempYamlCliFixture fs, ITestOutputHelpe
     [Theory]
     [Theory]
     [InlineData("switches", "routers")]
     [InlineData("switches", "routers")]
     [InlineData("firewalls", "routers")]
     [InlineData("firewalls", "routers")]
-    public async Task shrinking_port_count_removes_connections(string aType, string bType)
-    {
+    public async Task shrinking_port_count_removes_connections(string aType, string bType) {
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
 
 
         await ExecuteAsync(aType, "add", "node-a");
         await ExecuteAsync(aType, "add", "node-a");
@@ -138,8 +133,7 @@ public class PortConnectionWorkflowTests(TempYamlCliFixture fs, ITestOutputHelpe
     [Theory]
     [Theory]
     [InlineData("switches", "routers")]
     [InlineData("switches", "routers")]
     [InlineData("firewalls", "routers")]
     [InlineData("firewalls", "routers")]
-    public async Task shrinking_port_count_preserves_valid_connections(string aType, string bType)
-    {
+    public async Task shrinking_port_count_preserves_valid_connections(string aType, string bType) {
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
         await File.WriteAllTextAsync(Path.Combine(fs.Root, "config.yaml"), "");
 
 
         await ExecuteAsync(aType, "add", "node-a");
         await ExecuteAsync(aType, "add", "node-a");