// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using AWS.Deploy.Orchestration.Utilities;
namespace AWS.Deploy.CLI.UnitTests.Utilities
{
///
/// The container that represents a command to be executed by
///
public class CommandLineRunObject
{
///
/// The command to be executed via the command line wrapper.
///
public string Command { get; set; }
///
/// The working directory from which the command will be executed.
///
public string WorkingDirectory { get; set; }
///
/// Specifies whether to stream the output of the command execution to the interactive service.
///
public bool StreamOutputToInteractiveService { get; set; }
///
/// The action to run upon the completion of the command execution.
///
public Action OnCompleteAction { get; set; }
///
/// Specifies whether to redirect standard input, output and error.
///
public bool RedirectIO { get; set; }
///
/// Specifies the input that should be piped into standard input for the process.
///
public string Stdin { get; set; }
///
/// The cancellation token for the async task.
///
public CancellationToken CancelToken { get; set; }
}
public class TestToolCommandLineWrapper : ICommandLineWrapper
{
public List CommandsToExecute = new List();
public Task Run(
string command,
string workingDirectory = "",
bool streamOutputToInteractiveService = true,
Action onComplete = null,
bool redirectIO = true,
string stdin = null,
IDictionary environmentVariables = null,
CancellationToken cancelToken = default,
bool needAwsCredentials = false)
{
CommandsToExecute.Add(new CommandLineRunObject
{
Command = command,
WorkingDirectory = workingDirectory,
StreamOutputToInteractiveService = streamOutputToInteractiveService,
OnCompleteAction = onComplete,
RedirectIO = redirectIO,
Stdin = stdin,
CancelToken = cancelToken
});
return Task.CompletedTask;
}
public void ConfigureProcess(Action processStartInfoAction) => throw new NotImplementedException();
}
}