Add versioning to Info command

This commit is contained in:
2022-12-19 20:24:35 +01:00
parent e75f853e6a
commit 3a0d5fea9a
4 changed files with 29 additions and 1 deletions

View File

@@ -0,0 +1,6 @@
namespace Alma.Services;
public interface IVersionService
{
public string GetVersion();
}

View File

@@ -13,24 +13,30 @@ public class InfoCommand : ICommand
private readonly IRepositoryConfiguration _repositoryConfiguration;
private readonly ILogger<InfoCommand> _logger;
private readonly IOsInformation _osInformation;
private readonly IVersionService _versionService;
public InfoCommand(
IFolderService folderService,
IRepositoryConfiguration repositoryConfiguration,
ILogger<InfoCommand> logger,
IOsInformation osInformation
IOsInformation osInformation,
IVersionService versionService
)
{
_folderService = folderService;
_repositoryConfiguration = repositoryConfiguration;
_logger = logger;
_osInformation = osInformation;
_versionService = versionService;
}
public async Task Run(List<string> parameters)
{
//Add info REPO
//Add info REPO MODULE
_logger.LogInformation("Alma " + _versionService.GetVersion());
_logger.LogInformation("");
_logger.LogInformation("AppData folder: " + _folderService.AppData);
if (_folderService.ConfigRoot is { } configRoot)

View File

@@ -50,6 +50,7 @@ public static class Program
[Singleton(typeof(IModuleConfigurationResolver), typeof(ModuleConfigurationResolver))]
[Singleton(typeof(IMetadataHandler), typeof(MetadataHandler))]
[Singleton(typeof(IShellService), typeof(ShellService))]
[Singleton(typeof(IVersionService), typeof(VersionService))]
[Singleton(typeof(Application))]
[Transient(typeof(ILogger<>), Factory = nameof(CustomLoggerFactory))]
internal partial class AlmaServiceProvider

View File

@@ -0,0 +1,15 @@
using System.Reflection;
using Alma.Services;
namespace Alma;
public class VersionService : IVersionService
{
public string GetVersion()
{
return
typeof(Program).Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion
?? typeof(Program).Assembly.GetName().Version?.ToString()
?? "unknown";
}
}