Browse Source

Fix namespaces

pull/1089/head
Halil ibrahim Kalkan 7 years ago
parent
commit
3fa617b092
  1. 3
      framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgs.cs
  2. 21
      framework/src/Volo.Abp.Cli/Volo/Abp/Cli/CliService.cs
  3. 12
      framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/CommandSelector.cs
  4. 7
      framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/ICommandSelector.cs
  5. 5
      framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/IConsoleCommand.cs
  6. 13
      framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/MainHelpCommand.cs
  7. 34
      framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs

3
framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Args/CommandLineArgs.cs

@ -1,9 +1,8 @@
using System.Linq;
using System.Text;
using JetBrains.Annotations;
using Volo.Abp.Cli.Args;
namespace Volo.Abp.Cli
namespace Volo.Abp.Cli.Args
{
public class CommandLineArgs
{

21
framework/src/Volo.Abp.Cli/Volo/Abp/Cli/CliService.cs

@ -1,6 +1,8 @@
using System;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Threading.Tasks;
using Volo.Abp.Cli.Args;
using Volo.Abp.Cli.Commands;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Cli
@ -9,21 +11,28 @@ namespace Volo.Abp.Cli
{
protected ICommandLineArgumentParser CommandLineArgumentParser { get; }
protected ICommandSelector CommandSelector { get; }
public IHybridServiceScopeFactory ServiceScopeFactory { get; }
public CliService(
ICommandLineArgumentParser commandLineArgumentParser,
ICommandSelector commandSelector)
ICommandLineArgumentParser commandLineArgumentParser,
ICommandSelector commandSelector,
IHybridServiceScopeFactory serviceScopeFactory)
{
CommandLineArgumentParser = commandLineArgumentParser;
CommandSelector = commandSelector;
ServiceScopeFactory = serviceScopeFactory;
}
public async Task RunAsync(string[] args)
{
var commandLineArgs = CommandLineArgumentParser.Parse(args);
var command = CommandSelector.Select(commandLineArgs);
await command.ExecuteAsync();
Console.WriteLine(commandLineArgs);
var commandType = CommandSelector.Select(commandLineArgs);
using (var scope = ServiceScopeFactory.CreateScope())
{
var command = (IConsoleCommand)scope.ServiceProvider.GetRequiredService(commandType);
await command.ExecuteAsync(commandLineArgs);
}
}
}
}

12
framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/CommandSelector.cs

@ -1,20 +1,22 @@
using Volo.Abp.DependencyInjection;
using System;
using Volo.Abp.Cli.Args;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Cli
namespace Volo.Abp.Cli.Commands
{
public class CommandSelector : ICommandSelector, ITransientDependency
{
public IConsoleCommand Select(CommandLineArgs commandLineArgs)
public Type Select(CommandLineArgs commandLineArgs)
{
//TODO: Create options to define commands
//TODO: Get from dependency injection instead of new?
if (commandLineArgs.Command == "new")
{
return new NewProjectCommand(commandLineArgs);
return typeof(NewProjectCommand);
}
return new MainHelpCommand(commandLineArgs);
return typeof(MainHelpCommand);
}
}
}

7
framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/ICommandSelector.cs

@ -1,7 +1,10 @@
namespace Volo.Abp.Cli
using System;
using Volo.Abp.Cli.Args;
namespace Volo.Abp.Cli.Commands
{
public interface ICommandSelector
{
IConsoleCommand Select(CommandLineArgs commandLineArgs);
Type Select(CommandLineArgs commandLineArgs);
}
}

5
framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/IConsoleCommand.cs

@ -1,9 +1,10 @@
using System.Threading.Tasks;
using Volo.Abp.Cli.Args;
namespace Volo.Abp.Cli
namespace Volo.Abp.Cli.Commands
{
public interface IConsoleCommand
{
Task ExecuteAsync();
Task ExecuteAsync(CommandLineArgs commandLineArgs);
}
}

13
framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/MainHelpCommand.cs

@ -1,16 +1,13 @@
using System;
using System.Threading.Tasks;
using Volo.Abp.Cli.Args;
using Volo.Abp.DependencyInjection;
namespace Volo.Abp.Cli
namespace Volo.Abp.Cli.Commands
{
public class MainHelpCommand : IConsoleCommand
public class MainHelpCommand : ITransientDependency
{
public MainHelpCommand(CommandLineArgs commandLineArgs)
{
}
public Task ExecuteAsync()
public Task ExecuteAsync(CommandLineArgs commandLineArgs)
{
Console.WriteLine("*********** ABP CLI ****************");
Console.WriteLine();

34
framework/src/Volo.Abp.Cli/Volo/Abp/Cli/Commands/NewProjectCommand.cs

@ -1,21 +1,41 @@
using System;
using System.Threading.Tasks;
using Volo.Abp.Cli.Args;
using Volo.Abp.DependencyInjection;
using Volo.Abp.SolutionTemplating;
using Volo.Abp.SolutionTemplating.Building;
namespace Volo.Abp.Cli
namespace Volo.Abp.Cli.Commands
{
public class NewProjectCommand : IConsoleCommand
public class NewProjectCommand : IConsoleCommand, ITransientDependency
{
protected CommandLineArgs CommandLineArgs { get; }
protected SolutionBuilder SolutionBuilder { get; }
public NewProjectCommand(CommandLineArgs commandLineArgs)
public NewProjectCommand(SolutionBuilder solutionBuilder)
{
CommandLineArgs = commandLineArgs;
SolutionBuilder = solutionBuilder;
}
public Task ExecuteAsync()
public async Task ExecuteAsync(CommandLineArgs commandLineArgs)
{
if (commandLineArgs.Target == null)
{
Console.WriteLine("Project name is missing.");
Console.WriteLine("Usage:");
Console.WriteLine(" abp new <project-name>");
Console.WriteLine("Example:");
Console.WriteLine(" abp new Acme.BookStore");
}
Console.WriteLine("TODO: Create new project");
return Task.CompletedTask;
//await SolutionBuilder.BuildAsync(
// null,
// commandLineArgs.Target,
// DatabaseProvider.EntityFrameworkCore,
// "...",
// true
//);
}
}
}
Loading…
Cancel
Save