dotnet-installer/src/dotnet/commands/dotnet-run/Program.cs

46 lines
1.2 KiB
C#
Raw Normal View History

// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using Microsoft.DotNet.Cli.CommandLine;
using Microsoft.DotNet.Cli.Utils;
2017-03-10 09:08:01 -08:00
using Microsoft.DotNet.Cli;
using Parser = Microsoft.DotNet.Cli.Parser;
2015-10-30 15:40:13 -07:00
2015-11-01 02:46:05 -08:00
namespace Microsoft.DotNet.Tools.Run
2015-10-30 15:40:13 -07:00
{
public partial class RunCommand
2015-10-30 15:40:13 -07:00
{
2017-03-10 09:08:01 -08:00
public static RunCommand FromArgs(string[] args, string msbuildPath = null)
{
var parser = Parser.Instance;
var result = parser.ParseFrom("dotnet run", args);
Reporter.Output.WriteLine(result.Diagram());
result.ShowHelpIfRequested();
return result["dotnet"]["run"].Value<RunCommand>();
}
public static int Run(string[] args)
2015-10-30 15:40:13 -07:00
{
DebugHelper.HandleDebugSwitch(ref args);
2017-03-10 09:08:01 -08:00
RunCommand cmd;
try
{
2017-03-10 09:08:01 -08:00
cmd = FromArgs(args);
}
catch (CommandCreationException e)
{
return e.ExitCode;
}
2017-03-10 09:08:01 -08:00
return cmd.Start();
2015-10-30 15:40:13 -07:00
}
}
}