Add versioning to Info command
This commit is contained in:
6
src/Alma.Abstraction/Services/IVersionService.cs
Normal file
6
src/Alma.Abstraction/Services/IVersionService.cs
Normal file
@@ -0,0 +1,6 @@
|
||||
namespace Alma.Services;
|
||||
|
||||
public interface IVersionService
|
||||
{
|
||||
public string GetVersion();
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
15
src/Alma/VersionService.cs
Normal file
15
src/Alma/VersionService.cs
Normal 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";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user