Update WireMock.Net.StandAlone

This commit is contained in:
Stef Heyenrath
2017-02-05 19:19:44 +01:00
parent 51cc74ad20
commit 63536c2ed0

View File

@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using CommandLineParser.Arguments;
using CommandLineParser.Exceptions;
using WireMock.Server;
@@ -9,11 +11,11 @@ namespace WireMock.Net.StandAlone
{
private class Options
{
[ValueArgument(typeof(string), 'u', "Urls", Description = "URL(s) to listen on", Optional = false, AllowMultiple = true)]
public string[] Urls;
[ValueArgument(typeof(string), 'u', "Urls", Description = "URL(s) to listen on.", Optional = true, AllowMultiple = true)]
public List<string> Urls { get; set; }
[SwitchArgument('p', "AllowPartialMapping", true, Description = "Allow Partial Mapping (default set to true)", Optional = true)]
public bool AllowPartialMapping;
[SwitchArgument('p', "AllowPartialMapping", true, Description = "Allow Partial Mapping (default set to true).", Optional = true)]
public bool AllowPartialMapping { get; set; }
}
static void Main(params string[] args)
@@ -21,13 +23,15 @@ namespace WireMock.Net.StandAlone
var options = new Options();
var parser = new CommandLineParser.CommandLineParser();
parser.ExtractArgumentAttributes(options);
parser.ParseCommandLine(args);
try
{
parser.ParseCommandLine(args);
var server = FluentMockServer.StartWithAdminInterface(options.Urls);
if (!options.Urls.Any())
options.Urls.Add("http://localhost:9090/");
var server = FluentMockServer.StartWithAdminInterface(options.Urls.ToArray());
if (options.AllowPartialMapping)
server.AllowPartialMapping();
@@ -39,7 +43,7 @@ namespace WireMock.Net.StandAlone
Console.WriteLine(e.Message);
parser.ShowUsage();
}
Console.WriteLine("Press any key to stop the server");
Console.ReadKey();
}