move dotnet-run

This commit is contained in:
Piotr Puszkiewicz 2017-03-10 10:13:11 -08:00
parent a751673172
commit 940dd6863a
4 changed files with 27 additions and 13 deletions

View file

@ -17,5 +17,14 @@ namespace Microsoft.DotNet.Cli
.Select(o => o.Value<T>())
.SingleOrDefault();
}
public static string SingleArgumentOrDefault(this AppliedOption parseResult, string alias)
{
return parseResult
.AppliedOptions
.Where(o => o.HasAlias(alias))
.Select(o => o.Arguments.Single())
.SingleOrDefault();
}
}
}
}

View file

@ -38,7 +38,12 @@ namespace Microsoft.DotNet.Cli
_value = value;
}
public override string ToString() => _value;
public override string ToString() => _value;
public static explicit operator string(ForwardedArgument argument)
{
return argument.ToString();
}
}
}
}
}

View file

@ -15,16 +15,16 @@ namespace Microsoft.DotNet.Cli
"run",
".NET Run Command",
Accept.ZeroOrMoreArguments
.MaterializeAs(o =>
{
return new RunCommand()
.MaterializeAs(o =>
{
Configuration = o.ValueOrDefault<string>("--configuration"),
Framework = o.ValueOrDefault<string>("--framework"),
Project = o.ValueOrDefault<string>("--project"),
Args = (IReadOnlyList<string>)o.Arguments
};
}),
return new RunCommand()
{
Configuration = o.SingleArgumentOrDefault("--configuration"),
Framework = o.SingleArgumentOrDefault("--framework"),
Project = o.SingleArgumentOrDefault("--project"),
Args = (IReadOnlyList<string>)o.Arguments
};
}),
CommonOptions.HelpOption(),
CommonOptions.ConfigurationOption(),
CommonOptions.FrameworkOption(),

View file

@ -64,4 +64,4 @@ namespace Microsoft.DotNet.Tests.ParserTests
.BeEquivalentTo("one");
}
}
}
}