/// <summary>Clone existing repository.</summary> /// <param name="parameters"><see cref="CloneRepositoryParameters"/>.</param> /// <exception cref="ArgumentNullException"><paramref name="parameters"/> == <c>null</c>.</exception> public void Invoke(CloneRepositoryParameters parameters) { /* * git clone [--template=<template_directory>] [-l] [-s] [--no-hardlinks] * [-q] [-n] [--bare] [--mirror] [-o <name>] [-b <name>] [-u <upload-pack>] * [--reference <repository>] [--depth <depth>] [--recursive] [--] <repository> [<directory>] */ Verify.Argument.IsNotNull(parameters, nameof(parameters)); try { if (!Directory.Exists(parameters.Path)) { Directory.CreateDirectory(parameters.Path); } } catch (Exception exc) when(!exc.IsCritical()) { throw new GitException(exc.Message, exc); } var command = _commandFactory(parameters, false); var output = _commandExecutor.ExecuteCommand(command, CommandExecutionFlags.None); output.ThrowOnBadReturnCode(); }
public string Execute(string path) { StringBuilder messages = new StringBuilder(); try { bool isValid = _validateFileType.IsValid(path); if (isValid) { IEnumerable <string> commands = _fileReader.ReadFile(path); if (commands != null) { foreach (string command in commands) { ICommandExecutor executpr = _provider.InitExecutor(command); string message = executpr.ExecuteCommand(command); messages.AppendLine(message); } } else { messages.Append("Invalid file path"); } } else { messages.Append("Invalid file type"); } return(messages.ToString()); } catch (Exception ex) { throw; } }
public void Handle(ArtistWasUpdated domainEvent) { Task <CommandResult> .Factory.StartNew(() => _commandExecutor.ExecuteCommand(new LookForLastFmInformation() { Artist = domainEvent.Artist })); }
public void Handle(Events.ArtistWasAdded domainEvent) { Task <CommandResult> .Factory.StartNew(() => _commandExecutor.ExecuteCommand(new FindArtistInformationOnExternalServices() { Artist = domainEvent.Artist })); }
public void Install() { ActivateItem(_initializingViewModel); Task.Run(async() => { try { await _executor.ExecuteCommand(Options); } catch (PackageNotFoundException e) { ActivateItem(e.CreateDialog()); } catch (InstallerException e) { ActivateItem(e.CreateDialog()); } catch (Win32Exception e) { ActivateItem(e.CreateDialog()); } catch (Exception e) { ActivateItem(e.CreateDialog()); } }); }
public async Task Start() { if (_isWorking) { return; } _isWorking = true; var offset = 0; while (_isWorking) { var updates = await _bot.GetUpdatesAsync(offset); foreach (var update in updates) { if (update.Type == UpdateType.MessageUpdate) { var command = new TelegramSimpleCommand(update); _executor.ExecuteCommand(command); } offset = update.Id + 1; } await Task.Delay(1000); } }
private void ExecuteNextCommand() { if (_injector.HasMapping <Action <IAsyncCommand, bool> >(AsyncCommandExecutedCallbackName)) { _injector.Unmap <Action <IAsyncCommand, bool> >(AsyncCommandExecutedCallbackName); } while (!IsAborted && _commandMappingQueue.Count > 0) { ICommandMapping mapping = _commandMappingQueue.Dequeue(); if (mapping != null) { _injector.Map <Action <IAsyncCommand, bool> >(AsyncCommandExecutedCallbackName).ToValue((Action <IAsyncCommand, bool>)CommandExecutedCallback); _commandExecutor.ExecuteCommand(mapping, _payload); return; } } if (IsAborted) { _commandMappingQueue.Clear(); _commandsAbortedCallback?.Invoke(); } else if (_commandMappingQueue.Count == 0) { _commandsExecutedCallback?.Invoke(); } }
public IActionResult ExecuteCommand([FromBody] JObject input) { if (input == null) { return(BadRequest()); } string command = input.Value <string>("command"); string workingDirectory = input.Value <string>("dir"); using (_tracer.Step("Executing " + command, new Dictionary <string, string> { { "CWD", workingDirectory } })) { try { CommandResult result = _commandExecutor.ExecuteCommand(command, workingDirectory); return(Ok(result)); } catch (CommandLineException ex) { _tracer.TraceError(ex); return(Ok(new CommandResult { Error = ex.Error, ExitCode = ex.ExitCode })); } catch (Exception ex) { _tracer.TraceError(ex); return(Ok(new CommandResult { Error = ex.ToString(), ExitCode = -1 })); } } }
public void Handle(UserDisconnectedWithSignalR domainEvent) { _commandExecutor.ExecuteCommand(new RemoveConnectionIdToUserCommand() { ConnectionId = domainEvent.ConnectionId, }); }
public HttpResponseMessage ExecuteCommand(JObject input) { if (input == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } string command = input.Value <string>("command"); string workingDirectory = input.Value <string>("dir"); using (_tracer.Step("Executing " + command, new Dictionary <string, string> { { "CWD", workingDirectory } })) { try { CommandResult result = _commandExecutor.ExecuteCommand(command, workingDirectory); return(Request.CreateResponse(HttpStatusCode.OK, result)); } catch (CommandLineException ex) { _tracer.TraceError(ex); return(Request.CreateResponse(HttpStatusCode.OK, new CommandResult { Error = ex.Error, ExitCode = ex.ExitCode })); } catch (Exception ex) { _tracer.TraceError(ex); return(Request.CreateResponse(HttpStatusCode.OK, new CommandResult { Error = ex.ToString(), ExitCode = -1 })); } } }
public void Handle(UserConnectedWithSignalR domainEvent) { _commandExecutor.ExecuteCommand(new AddConnectionIdToUserCommand() { Username = domainEvent.Username, ConnectionId = domainEvent.ConnectionId }); }
public void Invoke(TParameters parameters) { Verify.Argument.IsNotNull(parameters, nameof(parameters)); var command = _commandFactory(parameters); var output = _commandExecutor.ExecuteCommand(command, _flags); _resultHandler(parameters, output); }
public void Invoke(TParameters parameters) { Verify.Argument.IsNotNull(parameters, nameof(parameters)); var command = _commandFactory(parameters); var output = _commandExecutor.ExecuteCommand(command, _flags); output.ThrowOnBadReturnCode(); }
public void Invoke(TParameters parameters) { Verify.Argument.IsNotNull(parameters, "parameters"); var command = _commandFactory(parameters, false); var output = _commandExecutor.ExecuteCommand(command, null, CommandExecutionFlags.None); output.ThrowOnBadReturnCode(); }
public TOutput Invoke(TParameters parameters) { Verify.Argument.IsNotNull(parameters, nameof(parameters)); var command = _commandFactory(parameters); var output = _commandExecutor.ExecuteCommand(command, _flags); return(_resultParser(parameters, output)); }
private string GetMergedCommits(string branch, string head, string lineFormat) { var cmd = new LogCommand( LogCommand.TFormat(lineFormat), new CommandParameter(head + ".." + branch)); var output = _commandExecutor.ExecuteCommand(cmd, CommandExecutionFlags.None); output.ThrowOnBadReturnCode(); return(output.Output); }
public void ExecuteCommandTest() { ICommandExecutor target = CreateICommandExecutor(); // TODO: Initialize to an appropriate value ICatalog catalog = null; // TODO: Initialize to an appropriate value ICommand command = null; // TODO: Initialize to an appropriate value StringBuilder output = null; // TODO: Initialize to an appropriate value target.ExecuteCommand(catalog, command, output); Assert.Inconclusive("A method that does not return a value cannot be verified."); }
public IList <ReferencePushResult> Invoke(PushParameters parameters) { Verify.Argument.IsNotNull(parameters, nameof(parameters)); var command = _commandFactory(parameters, false); var output = _commandExecutor.ExecuteCommand(command, CommandExecutionFlags.None); output.ThrowOnBadReturnCode(); return(_resultsParser(output.Output)); }
private string ParseTagMessage(Command command, GitOutput output) { Assert.IsNotNull(output); output.ThrowOnBadReturnCode(); var parser = new GitParser(output.Output); while (!parser.IsAtEndOfLine) { parser.SkipLine(); } parser.SkipLine(); if (parser.RemainingSymbols > 1) { var message = parser.ReadStringUpTo(parser.Length - 1); const char c = '�'; if (message.ContainsAnyOf(c)) { output = _commandExecutor.ExecuteCommand(command, Encoding.Default, CommandExecutionFlags.None); output.ThrowOnBadReturnCode(); parser = new GitParser(output.Output); while (!parser.IsAtEndOfLine) { parser.SkipLine(); } parser.SkipLine(); if (parser.RemainingSymbols > 1) { message = parser.ReadStringUpTo(parser.Length - 1); } else { message = string.Empty; } } return(message); } else { return(string.Empty); } }
public HttpResponseMessage ExecuteCommand(JObject input) { if (input == null) { return(Request.CreateResponse(HttpStatusCode.BadRequest)); } string command = input.Value <string>("command"); CommandResult result = _commandExecutor.ExecuteCommand(command); return(Request.CreateResponse(HttpStatusCode.OK, result)); }
public IList <ReflogRecordData> Invoke(QueryReflogParameters parameters) { Verify.Argument.IsNotNull(parameters, "parameters"); var command = _commandFactory(parameters); var output = _commandExecutor.ExecuteCommand(command, CommandExecutionFlags.None); output.ThrowOnBadReturnCode(); var cache = new Dictionary <Hash, RevisionData>(Hash.EqualityComparer); var list = ParseResult1(output, cache); // get real commit parents command = GetCommand2(parameters); output = _commandExecutor.ExecuteCommand(command, CommandExecutionFlags.None); output.ThrowOnBadReturnCode(); var parser = new GitParser(output.Output); parser.ParseCommitParentsFromRaw(list.Select(rrd => rrd.Revision), cache); return(list); }
public void TestPlaceCommand(string commandText, int xPos, int yPos, Orientation orientation) { _mockMovementProcessor.Place(xPos, yPos, orientation).Returns(info => new ActionOutcome(OutcomeStatus.Success)); var outcome = _executor.ExecuteCommand(commandText); _mockMovementProcessor.Received().Place(xPos, yPos, orientation); outcome.Result.ShouldBe(OutcomeStatus.Success); }
static void Main(string[] args) { try { Program parkingLot = new Program(); if (args.Length == 1) { string filePath = args[0]; IInputFileReader fileReader = new InputFileReader(); IValidateFileType validateFileType = new ValidateFileType(); IExecuteFromFile fileExecutor = new ExecuteFromFile(parkingLot._provider, validateFileType, fileReader); string messages = fileExecutor.Execute(filePath); Console.WriteLine(messages); } else if (args.Length > 1) { Console.WriteLine("Takes only one argument"); } else { string result = string.Empty; bool isLive = true; while (isLive) { string userInputCommand = Console.ReadLine(); if (userInputCommand.Equals("exit")) { isLive = false; } else { ICommandExecutor executor = parkingLot._provider.InitExecutor(userInputCommand); if (executor != null) { result = executor.ExecuteCommand(userInputCommand); } else { result = "Invalid Command"; } Console.WriteLine(result); } } } } catch (Exception ex) { Console.WriteLine(ex.Message); } }
public IActionResult ExecuteCommand([FromForm] string cluster, [FromForm] string command) { var result = $"{cluster}:{command}\r\n"; var certificate = Path.Combine("/certificates", cluster, "kubeconfig"); try { result += _commandExecutor.ExecuteCommand($"{command} --kubeconfig={certificate}"); } catch (Exception ex) { result = ex.Message; } return(Ok(result)); }
public TOutput Invoke(TParameters parameters) { Verify.Argument.IsNotNull(parameters, "parameters"); var command = CreateCommand(parameters); var parser = CreateParser(); var stdOutReceiver = new AsyncTextParser(parser); var stdErrReceiver = new AsyncTextReader(); var exitCode = _commandExecutor.ExecuteCommand( command, stdOutReceiver, stdErrReceiver, GetExecutionFlags()); if (exitCode != 0) { HandleNonZeroExitCode(stdErrReceiver, exitCode); } return(parser.GetResult()); }
public void Run() { while (true) { string commandLine = this.userInterface.ReadLine(); if (commandLine == "end") { break; } var command = new Command(commandLine); string commandResult = commandExecutor.ExecuteCommand(command); if (commandResult != null) { this.userInterface.WriteLine(commandResult); } } }
public string AddOrUpdatePackage(string packageName, string version = null) { var versionArgument = string.Empty; if (!string.IsNullOrWhiteSpace(version)) { versionArgument = $" -v {version}"; } var result = _commandExecutor.ExecuteCommand("dotnet", $"add \"{FilePath}\" package {packageName}{versionArgument}"); if (result.ExitCode != 0) { throw new InvalidOperationException("dotnet command failed."); } return(GetVersionFromStdout(result.StdOut, packageName)); }
public byte[] Invoke(TParameters parameters) { Verify.Argument.IsNotNull(parameters, nameof(parameters)); var command = _commandFactory(parameters); var stdInReceiver = new AsyncBytesReader(); var stdErrReceiver = new AsyncTextReader(); var exitCode = _commandExecutor.ExecuteCommand( command, stdInReceiver, stdErrReceiver, CommandExecutionFlags.None); if (exitCode != 0) { throw new GitException(stdErrReceiver.GetText()); } return(stdInReceiver.GetBytes()); }
public void Run(JsonObject input) { _executor.ExecuteCommand((string)input["command"]); }
/// <summary> /// The launch sensor. /// </summary> /// <param name="caller"> /// The caller. /// </param> /// <param name="logger"> /// The logger. /// </param> /// <param name="filePath"> /// The file Path. /// </param> /// <param name="executor"></param> /// <param name="callBackHandlerIn"> /// The call back handler in. /// </param> /// <returns> /// The <see cref="Process"/>. /// </returns> public virtual FSharpList<string> LaunchSensor( object caller, EventHandler logger, string filePath, ICommandExecutor executor) { var commandline = "[" + Directory.GetParent(filePath) + "] : " + this.GetCommand() + " " + this.GetArguments() + " " + filePath; CxxPlugin.WriteLogMessage(caller, logger, commandline); executor.ExecuteCommand( this.GetCommand(), this.GetArguments() + " " + filePath, this.GetEnvironment(), string.Empty); return this.UseStdout ? executor.GetStdOut : executor.GetStdError; }
private CommandResult ExecuteCommand(TCommand command) { return(_commandExecutor.ExecuteCommand(command)); }