Browse Source

Created empty login/logout commands and CliOptions.

pull/1103/head
Halil ibrahim Kalkan 8 years ago
parent
commit
b74d703c03
  1. 6
      framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj
  2. 10
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs
  3. 8
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgs.cs
  4. 18
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs
  5. 15
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliOptions.cs
  6. 24
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CommandSelector.cs
  7. 31
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginCommand.cs
  8. 27
      framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LogoutCommand.cs

6
framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj

@ -24,4 +24,10 @@
<ProjectReference Include="..\Volo.Abp.Json\Volo.Abp.Json.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="System.Data.SqlXml">
<HintPath>C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.SqlXml.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

10
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs

@ -1,4 +1,5 @@
using System.Text;
using Volo.Abp.Cli.Commands;
using Volo.Abp.Domain;
using Volo.Abp.Json;
using Volo.Abp.Modularity;
@ -14,6 +15,15 @@ namespace Volo.Abp.Cli
public override void ConfigureServices(ServiceConfigurationContext context)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
Configure<CliOptions>(options =>
{
options.Commands["help"] = typeof(HelpCommand);
options.Commands["new"] = typeof(NewCommand);
options.Commands["add"] = typeof(AddCommand);
options.Commands["login"] = typeof(LoginCommand);
options.Commands["logout"] = typeof(LogoutCommand);
});
}
}
}

8
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgs.cs

@ -1,4 +1,5 @@
using System.Linq;
using System;
using System.Linq;
using System.Text;
using JetBrains.Annotations;
@ -27,6 +28,11 @@ namespace Volo.Abp.Cli.Args
return new CommandLineArgs();
}
public bool IsCommand(string command)
{
return string.Equals(Command, command, StringComparison.OrdinalIgnoreCase);
}
public override string ToString()
{
var sb = new StringBuilder();

18
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs

@ -0,0 +1,18 @@
using System.Threading.Tasks;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Cli.Auth
{
public class AuthService : ITransientDependency
{
public async Task LoginAsync(string userName, string password)
{
}
public async Task LogoutAsync()
{
}
}
}

15
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliOptions.cs

@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
namespace Volo.Abp.Cli
{
public class CliOptions
{
public Dictionary<string, Type> Commands { get; }
public CliOptions()
{
Commands = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreCase);
}
}
}

24
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CommandSelector.cs

@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using Microsoft.Extensions.Options;
using Volo.Abp.Cli.Args;
using Volo.Abp.DependencyInjection;
@ -6,21 +8,17 @@ namespace Volo.Abp.Cli.Commands
{
public class CommandSelector : ICommandSelector, ITransientDependency
{
public Type Select(CommandLineArgs commandLineArgs)
{
//TODO: Create options to define commands
protected CliOptions Options { get; }
if (commandLineArgs.Command == "new")
{
return typeof(NewCommand);
}
if (commandLineArgs.Command == "add")
{
return typeof(AddCommand);
}
public CommandSelector(IOptions<CliOptions> options)
{
Options = options.Value;
}
return typeof(HelpCommand);
public Type Select(CommandLineArgs commandLineArgs)
{
return Options.Commands.GetOrDefault(commandLineArgs.Command)
?? typeof(HelpCommand);
}
}
}

31
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginCommand.cs

@ -0,0 +1,31 @@
using System;
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.Cli.Args;
using Volo.Abp.Cli.Auth;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Cli.Commands
{
public class LoginCommand : IConsoleCommand, ITransientDependency
{
public ILogger<LoginCommand> Logger { get; set; }
protected AuthService AuthService { get; }
public LoginCommand(AuthService authService)
{
AuthService = authService;
Logger = NullLogger<LoginCommand>.Instance;
}
public async Task ExecuteAsync(CommandLineArgs commandLineArgs)
{
if (commandLineArgs.Target.IsNullOrEmpty())
{
}
}
}
}

27
framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LogoutCommand.cs

@ -0,0 +1,27 @@
using System.Threading.Tasks;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;
using Volo.Abp.Cli.Args;
using Volo.Abp.Cli.Auth;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Cli.Commands
{
public class LogoutCommand : IConsoleCommand, ITransientDependency
{
public ILogger<LogoutCommand> Logger { get; set; }
protected AuthService AuthService { get; }
public LogoutCommand(AuthService authService)
{
AuthService = authService;
Logger = NullLogger<LogoutCommand>.Instance;
}
public Task ExecuteAsync(CommandLineArgs commandLineArgs)
{
return AuthService.LogoutAsync();
}
}
}
Loading…
Cancel
Save