Add -h --help aliases for help
This commit is contained in:
@@ -2,6 +2,7 @@ namespace Alma.Command;
|
|||||||
|
|
||||||
public interface ICommand
|
public interface ICommand
|
||||||
{
|
{
|
||||||
public string CommandString { get; }
|
string CommandString { get; }
|
||||||
public Task Run(List<string> parameters);
|
string[] CommandAliases { get; }
|
||||||
|
Task Run(List<string> parameters);
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,4 @@
|
|||||||
using Alma.Command;
|
using Alma.Command;
|
||||||
using Alma.Command.Help;
|
|
||||||
using Alma.Logging;
|
using Alma.Logging;
|
||||||
|
|
||||||
namespace Alma;
|
namespace Alma;
|
||||||
|
|||||||
@@ -1,6 +1,5 @@
|
|||||||
using Alma.Command.Install;
|
using Alma.Command.Install;
|
||||||
using Alma.Configuration.Repository;
|
using Alma.Configuration.Repository;
|
||||||
using Alma.Data;
|
|
||||||
using Alma.Logging;
|
using Alma.Logging;
|
||||||
using Alma.Services;
|
using Alma.Services;
|
||||||
|
|
||||||
@@ -11,6 +10,7 @@ public class ConfigureCommand : RepositoryModuleCommandBase
|
|||||||
private readonly ILogger<InstallCommand> _logger;
|
private readonly ILogger<InstallCommand> _logger;
|
||||||
private readonly IShellService _shellService;
|
private readonly IShellService _shellService;
|
||||||
public override string CommandString => "configure";
|
public override string CommandString => "configure";
|
||||||
|
public override string[] CommandAliases => Array.Empty<string>();
|
||||||
|
|
||||||
public ConfigureCommand(
|
public ConfigureCommand(
|
||||||
ILogger<InstallCommand> logger,
|
ILogger<InstallCommand> logger,
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ public class DiagCommand : ICommand
|
|||||||
{
|
{
|
||||||
private readonly ILogger<DiagCommand> _logger;
|
private readonly ILogger<DiagCommand> _logger;
|
||||||
public string CommandString => "diag";
|
public string CommandString => "diag";
|
||||||
|
public string[] CommandAliases => Array.Empty<string>();
|
||||||
|
|
||||||
private readonly Lazy<IReadOnlyList<MethodInfo>> _diagnosticHelpersLazy;
|
private readonly Lazy<IReadOnlyList<MethodInfo>> _diagnosticHelpersLazy;
|
||||||
|
|
||||||
public DiagCommand(ILogger<DiagCommand> logger)
|
public DiagCommand(ILogger<DiagCommand> logger)
|
||||||
|
|||||||
@@ -9,6 +9,8 @@ public class HelpCommand : ICommand
|
|||||||
|
|
||||||
public string CommandString => "help";
|
public string CommandString => "help";
|
||||||
|
|
||||||
|
public string[] CommandAliases { get; } = ["--help", "-h"];
|
||||||
|
|
||||||
public HelpCommand(
|
public HelpCommand(
|
||||||
IServiceProvider serviceProvider,
|
IServiceProvider serviceProvider,
|
||||||
ILogger<HelpCommand> logger
|
ILogger<HelpCommand> logger
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ namespace Alma.Command.Info;
|
|||||||
public class InfoCommand : RepositoryModuleCommandBase
|
public class InfoCommand : RepositoryModuleCommandBase
|
||||||
{
|
{
|
||||||
public override string CommandString => "info";
|
public override string CommandString => "info";
|
||||||
|
public override string[] CommandAliases => Array.Empty<string>();
|
||||||
|
|
||||||
private readonly IFolderService _folderService;
|
private readonly IFolderService _folderService;
|
||||||
private readonly IRepositoryConfiguration _repositoryConfiguration;
|
private readonly IRepositoryConfiguration _repositoryConfiguration;
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System.Diagnostics;
|
|
||||||
using Alma.Configuration.Repository;
|
using Alma.Configuration.Repository;
|
||||||
using Alma.Data;
|
|
||||||
using Alma.Logging;
|
using Alma.Logging;
|
||||||
using Alma.Services;
|
using Alma.Services;
|
||||||
|
|
||||||
@@ -11,6 +9,7 @@ public class InstallCommand : RepositoryModuleCommandBase
|
|||||||
private readonly ILogger<InstallCommand> _logger;
|
private readonly ILogger<InstallCommand> _logger;
|
||||||
private readonly IShellService _shellService;
|
private readonly IShellService _shellService;
|
||||||
public override string CommandString => "install";
|
public override string CommandString => "install";
|
||||||
|
public override string[] CommandAliases => Array.Empty<string>();
|
||||||
|
|
||||||
public InstallCommand(
|
public InstallCommand(
|
||||||
ILogger<InstallCommand> logger,
|
ILogger<InstallCommand> logger,
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using System.Runtime.InteropServices;
|
|||||||
using Alma.Configuration.Module;
|
using Alma.Configuration.Module;
|
||||||
using Alma.Configuration.Repository;
|
using Alma.Configuration.Repository;
|
||||||
using Alma.Data;
|
using Alma.Data;
|
||||||
using Alma.Helper;
|
|
||||||
using Alma.Logging;
|
using Alma.Logging;
|
||||||
using Alma.Services;
|
using Alma.Services;
|
||||||
|
|
||||||
@@ -17,6 +16,7 @@ public class LinkCommand : RepositoryModuleCommandBase
|
|||||||
private readonly ILogger<LinkCommand> _logger;
|
private readonly ILogger<LinkCommand> _logger;
|
||||||
|
|
||||||
public override string CommandString => "link";
|
public override string CommandString => "link";
|
||||||
|
public override string[] CommandAliases => Array.Empty<string>();
|
||||||
|
|
||||||
public LinkCommand(
|
public LinkCommand(
|
||||||
IRepositoryConfiguration repositoryConfiguration,
|
IRepositoryConfiguration repositoryConfiguration,
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ public class ListCommand : ICommand
|
|||||||
private readonly ILogger<ListCommand> _logger;
|
private readonly ILogger<ListCommand> _logger;
|
||||||
|
|
||||||
public string CommandString => "ls";
|
public string CommandString => "ls";
|
||||||
|
public string[] CommandAliases => Array.Empty<string>();
|
||||||
|
|
||||||
public ListCommand(
|
public ListCommand(
|
||||||
IRepositoryConfiguration repositoryConfiguration,
|
IRepositoryConfiguration repositoryConfiguration,
|
||||||
|
|||||||
@@ -10,6 +10,8 @@ public abstract class RepositoryModuleCommandBase : ICommand
|
|||||||
private readonly IModuleConfigurationResolver _moduleConfigurationResolver;
|
private readonly IModuleConfigurationResolver _moduleConfigurationResolver;
|
||||||
private readonly IPathHelperService _pathHelperService;
|
private readonly IPathHelperService _pathHelperService;
|
||||||
public abstract string CommandString { get; }
|
public abstract string CommandString { get; }
|
||||||
|
public abstract string[] CommandAliases { get; }
|
||||||
|
|
||||||
public abstract Task Run(List<string> parameters);
|
public abstract Task Run(List<string> parameters);
|
||||||
|
|
||||||
protected RepositoryModuleCommandBase(
|
protected RepositoryModuleCommandBase(
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ namespace Alma.Command.Unlink;
|
|||||||
public class UnlinkCommand : ICommand
|
public class UnlinkCommand : ICommand
|
||||||
{
|
{
|
||||||
public string CommandString => "unlink";
|
public string CommandString => "unlink";
|
||||||
|
public string[] CommandAliases => Array.Empty<string>();
|
||||||
public Task Run(List<string> parameters)
|
public Task Run(List<string> parameters)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
|
|||||||
@@ -19,7 +19,14 @@ public class ConfigurationFileReader
|
|||||||
{
|
{
|
||||||
foreach (var configurationFileReader in _configurationFileReaders)
|
foreach (var configurationFileReader in _configurationFileReaders)
|
||||||
{
|
{
|
||||||
if (await configurationFileReader.DeserializeAsync<T>(fileNameWithoutExtension, contextGenerator, extension) is { Result: { } } result) return result;
|
if (await configurationFileReader.DeserializeAsync<T>(
|
||||||
|
fileNameWithoutExtension,
|
||||||
|
contextGenerator,
|
||||||
|
extension) is { Result: { } } result
|
||||||
|
)
|
||||||
|
{
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (null, null);
|
return (null, null);
|
||||||
|
|||||||
@@ -17,6 +17,12 @@ public class JsonConfigurationFileReader : IConfigurationFileReader
|
|||||||
if (!File.Exists(fileName)) return (null, null);
|
if (!File.Exists(fileName)) return (null, null);
|
||||||
|
|
||||||
await using FileStream openStream = File.OpenRead(fileName);
|
await using FileStream openStream = File.OpenRead(fileName);
|
||||||
return ((T?)await JsonSerializer.DeserializeAsync(openStream, typeof(T), contextGenerator(new JsonSerializerOptions(DefaultOptions))), fileName);
|
var result =
|
||||||
|
(T?)await JsonSerializer.DeserializeAsync(
|
||||||
|
openStream,
|
||||||
|
typeof(T),
|
||||||
|
contextGenerator(new JsonSerializerOptions(DefaultOptions))
|
||||||
|
);
|
||||||
|
return (result, fileName);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<VersionPrefix>0.0.0</VersionPrefix>
|
<VersionPrefix>0.0.4</VersionPrefix>
|
||||||
<VersionSuffix>development</VersionSuffix>
|
<VersionSuffix>development</VersionSuffix>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
using System.IO;
|
using Alma.Command;
|
||||||
using System;
|
|
||||||
using Alma.Command;
|
|
||||||
using Alma.Command.Configure;
|
using Alma.Command.Configure;
|
||||||
using Alma.Command.Diag;
|
using Alma.Command.Diag;
|
||||||
using Alma.Command.Help;
|
using Alma.Command.Help;
|
||||||
|
|||||||
Reference in New Issue
Block a user