diff --git a/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj b/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj
index 07a488123c..df4d76cce5 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj
+++ b/framework/src/Volo.Abp.Cli.Core/Volo.Abp.Cli.Core.csproj
@@ -24,4 +24,10 @@
+
+
+ C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.SqlXml.dll
+
+
+
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs
index 555fe14ca4..eaa7aa0175 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/AbpCliCoreModule.cs
+++ b/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(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);
+ });
}
}
}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgs.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgs.cs
index 624c96afe5..5e1191c385 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Args/CommandLineArgs.cs
+++ b/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();
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Auth/AuthService.cs
new file mode 100644
index 0000000000..692e699e75
--- /dev/null
+++ b/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()
+ {
+
+ }
+ }
+}
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliOptions.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/CliOptions.cs
new file mode 100644
index 0000000000..3885314e70
--- /dev/null
+++ b/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 Commands { get; }
+
+ public CliOptions()
+ {
+ Commands = new Dictionary(StringComparer.OrdinalIgnoreCase);
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CommandSelector.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CommandSelector.cs
index 9bcc5ed859..d3d3d7c736 100644
--- a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/CommandSelector.cs
+++ b/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 options)
+ {
+ Options = options.Value;
+ }
- return typeof(HelpCommand);
+ public Type Select(CommandLineArgs commandLineArgs)
+ {
+ return Options.Commands.GetOrDefault(commandLineArgs.Command)
+ ?? typeof(HelpCommand);
}
}
}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LoginCommand.cs
new file mode 100644
index 0000000000..e1a215b201
--- /dev/null
+++ b/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 Logger { get; set; }
+
+ protected AuthService AuthService { get; }
+
+ public LoginCommand(AuthService authService)
+ {
+ AuthService = authService;
+ Logger = NullLogger.Instance;
+ }
+
+ public async Task ExecuteAsync(CommandLineArgs commandLineArgs)
+ {
+ if (commandLineArgs.Target.IsNullOrEmpty())
+ {
+
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LogoutCommand.cs b/framework/src/Volo.Abp.Cli.Core/Volo/Abp/Cli/Commands/LogoutCommand.cs
new file mode 100644
index 0000000000..342e52f529
--- /dev/null
+++ b/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 Logger { get; set; }
+
+ protected AuthService AuthService { get; }
+
+ public LogoutCommand(AuthService authService)
+ {
+ AuthService = authService;
+ Logger = NullLogger.Instance;
+ }
+
+ public Task ExecuteAsync(CommandLineArgs commandLineArgs)
+ {
+ return AuthService.LogoutAsync();
+ }
+ }
+}
\ No newline at end of file