blob: c5b7a030ef9173dbbe082901d854482efd43797f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
using System;
using System.Collections.Generic;
using System.IO;
using System.IO.Pipes;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Tango.StubsUtils.Shared;
namespace Tango.StubsUtils.ProcedureClient.CLI
{
class Program
{
private const string PIPE_NAME = "Tango_Stubs_Server";
static void Main(string[] args)
{
try
{
Console.ForegroundColor = ConsoleColor.Gray;
var _client = new NamedPipeClientStream(PIPE_NAME);
_client.Connect(1000);
var writer = new StreamWriter(_client);
String s = Environment.CommandLine;
List<String> arguments = args.ToList();
arguments.Insert(0, "procedure");
var request = String.Join("^", arguments);
writer.WriteLine(request);
writer.Flush();
var reader = new StreamReader(_client);
while (true)
{
String responseString = reader.ReadLine();
Console.WriteLine(responseString);
if (responseString.StartsWith("Status: OK"))
{
responseString = reader.ReadToEnd();
Console.WriteLine(responseString);
Environment.Exit(0);
}
else if (responseString.StartsWith("Status: Error"))
{
responseString = reader.ReadToEnd();
Console.WriteLine(responseString);
ExitError(responseString);
}
}
}
catch (Exception ex)
{
ExitError($"Status: Error\nError: Error communicating with the stubs service. {ex.Message}");
}
}
private static void ExitError(String error)
{
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine($"{error}");
Console.ForegroundColor = ConsoleColor.Gray;
Environment.Exit(-1);
}
}
}
|