Skip to content

Commit 875700a

Browse files
committed
runscript: Specify request file. New command viewscript
1 parent b85b02d commit 875700a

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

netmockery/Program.cs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,11 @@ public static void Main(string[] args)
5858
case "runscript":
5959
RunScript(commandArgs);
6060
break;
61+
62+
case "viewscript":
63+
ViewScript(commandArgs);
64+
break;
65+
6166
default:
6267
Error.WriteLine($"Unknown command {commandName}");
6368
break;
@@ -76,10 +81,19 @@ public static void RunScript(string[] commandArgs)
7681
var scriptfile = commandArgs[0];
7782

7883
var responseCreator = new FileDynamicResponseCreator(scriptfile);
79-
var body = responseCreator.GetBody(new RequestInfo { EndpointDirectory = Path.GetDirectoryName(scriptfile) });
84+
var body = responseCreator.GetBody(new RequestInfo {
85+
RequestBody = commandArgs.Length == 2 ? File.ReadAllText(commandArgs[1]) : "",
86+
EndpointDirectory = Path.GetDirectoryName(scriptfile)
87+
});
8088
Console.WriteLine(body);
8189
}
8290

91+
public static void ViewScript(string[] commandArgs)
92+
{
93+
var scriptfile = commandArgs[0];
94+
Console.WriteLine(DynamicResponseCreatorBase.ExecuteIncludes(File.ReadAllText(scriptfile), Path.GetDirectoryName(scriptfile)));
95+
}
96+
8397
public static void Match(string[] args)
8498
{
8599
var path = args[0];

0 commit comments

Comments
 (0)