diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 5a5b967..48ed564 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -19,6 +19,9 @@ jobs: - os: ubuntu-latest rid: linux-x64 name: linux-x64 + - os: ubuntu-latest + rid: linux-arm64 + name: linux-arm64 - os: windows-latest rid: win-x64 name: windows-x64 diff --git a/src/Module.cs b/src/Module.cs index 2737586..74f9d5b 100644 --- a/src/Module.cs +++ b/src/Module.cs @@ -1,3 +1,5 @@ +using System.CommandLine; +using Hypr.Commands; using Hypr.Configuration; using Hypr.Hooks; using Hypr.Services; @@ -10,64 +12,74 @@ namespace Hypr; internal static class Module { - internal static IServiceCollection AddServices(this IServiceCollection services, IConfiguration configuration) => services - .Configure(configuration.GetSection("terminal")) - .Configure(configuration.GetSection("worktree")) - .Configure(configuration.GetSection("cleanup")) - .Configure(configuration.GetSection("scripts")) - .Configure(configuration.GetSection("confirmations")) - .AddSingleton() - .AddSingleton() - .AddSingleton() - .AddSingleton() - .AddSingleton() - .AddSingleton() - .AddTerminalProviders(); + internal static IServiceCollection AddServices(this IServiceCollection services, IConfiguration configuration) => services + // Configuration sections + .Configure(configuration.GetSection("terminal")) + .Configure(configuration.GetSection("worktree")) + .Configure(configuration.GetSection("cleanup")) + .Configure(configuration.GetSection("scripts")) + .Configure(configuration.GetSection("confirmations")) + // Services + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton() + // Commands and terminal providers (explicit registration for commands, Scrutor for terminal providers) + .AddCommands() + .AddTerminalProviders(); - private static IServiceCollection AddTerminalProviders(this IServiceCollection services) - { - var currentPlatform = GetCurrentPlatform(); + internal static IServiceCollection AddCommands(this IServiceCollection services) => services + .AddSingleton() + .AddSingleton() + .AddSingleton() + .AddSingleton(); - // Use Scrutor to scan and register all terminal providers that support the current platform - services.Scan(scan => scan - .FromAssemblyOf() - .AddClasses(classes => classes - .AssignableTo() - .Where(type => SupportsCurrentPlatform(type, currentPlatform))) - .AsImplementedInterfaces() - .WithSingletonLifetime()); + private static IServiceCollection AddTerminalProviders(this IServiceCollection services) + { + var currentPlatform = GetCurrentPlatform(); - return services; - } + // Use Scrutor to scan and register all terminal providers that support current platform + services.Scan(scan => scan + .FromAssemblyOf() + .AddClasses(classes => classes + .AssignableTo() + .Where(type => SupportsCurrentPlatform(type, currentPlatform))) + .AsImplementedInterfaces() + .WithSingletonLifetime()); - private static Platform GetCurrentPlatform() - { - if (PlatformUtils.IsWindows) return Platform.Windows; - if (PlatformUtils.IsMacOS) return Platform.MacOS; - if (PlatformUtils.IsLinux) return Platform.Linux; - return Platform.None; - } + return services; + } - private static bool SupportsCurrentPlatform(Type providerType, Platform currentPlatform) - { - return GetSupportedPlatformsForType(providerType).HasFlag(currentPlatform); - } + private static Platform GetCurrentPlatform() + { + if (PlatformUtils.IsWindows) return Platform.Windows; + if (PlatformUtils.IsMacOS) return Platform.MacOS; + if (PlatformUtils.IsLinux) return Platform.Linux; + return Platform.None; + } + + private static bool SupportsCurrentPlatform(Type providerType, Platform currentPlatform) + { + return GetSupportedPlatformsForType(providerType).HasFlag(currentPlatform); + } - private static Platform GetSupportedPlatformsForType(Type providerType) + private static Platform GetSupportedPlatformsForType(Type providerType) + { + // Map known provider types to their supported platforms + return providerType.Name switch { - // Map known provider types to their supported platforms - return providerType.Name switch - { - nameof(WindowsTerminalProvider) => Platform.Windows, - nameof(ITerm2Provider) => Platform.MacOS, - nameof(TerminalAppProvider) => Platform.MacOS, - nameof(GnomeTerminalProvider) => Platform.Linux, - nameof(TmuxProvider) => Platform.Linux | Platform.MacOS, - nameof(VSCodeProvider) => Platform.All, - nameof(CursorProvider) => Platform.All, - nameof(EchoProvider) => Platform.All, - nameof(InplaceProvider) => Platform.All, - _ => Platform.None - }; - } -} + nameof(WindowsTerminalProvider) => Platform.Windows, + nameof(ITerm2Provider) => Platform.MacOS, + nameof(TerminalAppProvider) => Platform.MacOS, + nameof(GnomeTerminalProvider) => Platform.Linux, + nameof(TmuxProvider) => Platform.Linux | Platform.MacOS, + nameof(VSCodeProvider) => Platform.All, + nameof(CursorProvider) => Platform.All, + nameof(EchoProvider) => Platform.All, + nameof(InplaceProvider) => Platform.All, + _ => Platform.None + }; + } +} \ No newline at end of file diff --git a/src/Program.cs b/src/Program.cs index de959cf..cc38192 100644 --- a/src/Program.cs +++ b/src/Program.cs @@ -1,5 +1,4 @@ using System.CommandLine; -using Hypr.Commands; using Hypr.Configuration; using Hypr.Logging; using Microsoft.Extensions.Configuration; @@ -26,14 +25,9 @@ // Register configuration builder.Services.AddSingleton(configuration); -// Register services and configuration sections +// Register services, configuration sections, and commands builder.Services.AddServices(builder.Configuration); -// Automatically discover and register all commands -builder.Services.Scan(s => s.FromAssemblyOf() - .AddClasses(c => c.AssignableTo()) - .As()); - var host = builder.Build(); var rootCommand = new RootCommand("hypr - Git worktree manager"); rootCommand.Options.Add(new DebugOption()); diff --git a/src/hypr.csproj b/src/hypr.csproj index 69c370a..8a7838a 100644 --- a/src/hypr.csproj +++ b/src/hypr.csproj @@ -29,10 +29,12 @@ true link true + + true - + @@ -50,7 +52,7 @@ - - - + + +