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