2015-11-16 11:21:57 -08:00
|
|
|
|
// 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.
|
|
|
|
|
|
2015-11-20 19:00:56 -08:00
|
|
|
|
using System;
|
2016-04-19 22:51:32 -05:00
|
|
|
|
using Microsoft.DotNet.Cli.CommandLine;
|
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
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
|
|
|
|
{
|
2016-01-30 21:47:50 -08:00
|
|
|
|
public partial class RunCommand
|
2015-10-30 15:40:13 -07:00
|
|
|
|
{
|
2016-01-30 21:47:50 -08:00
|
|
|
|
public static int Run(string[] args)
|
2015-10-30 15:40:13 -07:00
|
|
|
|
{
|
|
|
|
|
DebugHelper.HandleDebugSwitch(ref args);
|
|
|
|
|
|
2016-04-22 16:01:17 -05:00
|
|
|
|
CommandLineApplication app = new CommandLineApplication(throwOnUnexpectedArg: false);
|
2016-04-19 22:51:32 -05:00
|
|
|
|
app.Name = "dotnet run";
|
|
|
|
|
app.FullName = ".NET Run Command";
|
|
|
|
|
app.Description = "Command used to run .NET apps";
|
2016-04-20 00:28:34 -05:00
|
|
|
|
app.HandleResponseFiles = true;
|
2016-04-22 16:01:17 -05:00
|
|
|
|
app.AllowArgumentSeparator = true;
|
2016-10-27 18:46:43 -07:00
|
|
|
|
app.ArgumentSeparatorHelpText = HelpMessageStrings.MSBuildAdditionalArgsHelpText;
|
2016-04-19 22:51:32 -05:00
|
|
|
|
app.HelpOption("-h|--help");
|
2015-12-18 10:30:04 -08:00
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
CommandOption configuration = app.Option(
|
|
|
|
|
"-c|--configuration", "Configuration under which to build",
|
|
|
|
|
CommandOptionType.SingleValue);
|
|
|
|
|
CommandOption framework = app.Option(
|
|
|
|
|
"-f|--framework <FRAMEWORK>", "Compile a specific framework",
|
|
|
|
|
CommandOptionType.SingleValue);
|
|
|
|
|
CommandOption project = app.Option(
|
|
|
|
|
"-p|--project", "The path to the project file to run (defaults to the current directory if there is only one project).",
|
|
|
|
|
CommandOptionType.SingleValue);
|
2015-12-18 10:30:04 -08:00
|
|
|
|
|
2016-04-19 22:51:32 -05:00
|
|
|
|
app.OnExecute(() =>
|
2015-12-18 10:30:04 -08:00
|
|
|
|
{
|
2016-04-19 22:51:32 -05:00
|
|
|
|
RunCommand runCmd = new RunCommand();
|
2015-12-18 10:30:04 -08:00
|
|
|
|
|
2016-04-19 22:51:32 -05:00
|
|
|
|
runCmd.Configuration = configuration.Value();
|
2016-10-27 18:46:43 -07:00
|
|
|
|
runCmd.Framework = framework.Value();
|
2016-04-19 22:51:32 -05:00
|
|
|
|
runCmd.Project = project.Value();
|
2016-04-22 16:01:17 -05:00
|
|
|
|
runCmd.Args = app.RemainingArguments;
|
2015-10-30 15:40:13 -07:00
|
|
|
|
|
2016-04-19 22:51:32 -05:00
|
|
|
|
return runCmd.Start();
|
|
|
|
|
});
|
2016-04-20 00:28:34 -05:00
|
|
|
|
|
2016-10-27 18:46:43 -07:00
|
|
|
|
return app.Execute(args);
|
2015-10-30 15:40:13 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|