public CommandHostContext CreateContext()
        {
            var context = new CommandHostContext { RetryResult = CommandReturnCodes.Retry };

            _logger.LogInfo("Initializing Orchard session.");
            Initialize(context);
            return context;
        }
        private void Initialize(CommandHostContext context)
        {
            context.Arguments = new OrchardParametersParser().Parse(new CommandParametersParser().Parse(_args));

            // Perform some argument validation and display usage if something is incorrect
            context.DisplayUsageHelp = context.Arguments.Switches.ContainsKey("?");
            if (context.DisplayUsageHelp)
                return;

            context.DisplayUsageHelp = (context.Arguments.Arguments.Any() && context.Arguments.ResponseFiles.Any());
            if (context.DisplayUsageHelp) {
                _logger.LogError("Incorrect syntax: Response files cannot be used in conjunction with commands");
                return;
            }

            context.StartSessionResult = CommandReturnCodes.Ok;
        }
Esempio n. 3
0
 public CommandReturnCodes ExecuteInteractive(CommandHostContext context)
 {
     _output.WriteLine("Type \"?\" for help, \"exit\" to exit, \"cls\" to clear screen");
     while (true) {
         var command = ReadCommand(context);
         switch (command.ToLowerInvariant()) {
             case "quit":
             case "q":
             case "exit":
             case "e":
                 return 0;
             case "help":
             case "?":
                 DisplayInteractiveHelp();
                 break;
             case "cls":
                 //System.Console..Clear();
                 break;
             default:
                 //context = RunCommand(context, command);
                 break;
         }
     }
 }
Esempio n. 4
0
 private string ReadCommand(CommandHostContext context)
 {
     _output.WriteLine();
     _output.Write("orchard> ");
     return _input.ReadLine();
 }
 public void Shutdown(CommandHostContext context)
 {
     _logger.LogInfo("Shutting down Orchard session");
 }
Esempio n. 6
0
 public void Shutdown(CommandHostContext context)
 {
     _logger.LogInfo("Shutting down Orchard session");
 }