2017-04-12 16:03:45 -07:00
|
|
|
|
using System;
|
2017-03-09 10:53:17 -08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using Microsoft.DotNet.Cli.CommandLine;
|
|
|
|
|
using Microsoft.DotNet.Cli.Utils;
|
|
|
|
|
|
|
|
|
|
namespace Microsoft.DotNet.Cli
|
|
|
|
|
{
|
|
|
|
|
public class ParseCommand
|
|
|
|
|
{
|
|
|
|
|
public static int Run(string[] args)
|
|
|
|
|
{
|
|
|
|
|
DebugHelper.HandleDebugSwitch(ref args);
|
|
|
|
|
|
2017-03-15 13:59:39 -07:00
|
|
|
|
ParseResult result;
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
result = Parser.Instance.Parse(
|
2017-03-09 10:53:17 -08:00
|
|
|
|
args.Single());
|
2017-03-15 13:59:39 -07:00
|
|
|
|
}
|
|
|
|
|
catch (Exception e)
|
|
|
|
|
{
|
|
|
|
|
throw new InvalidOperationException("The parser threw an exception.", e);
|
|
|
|
|
}
|
2017-03-09 10:53:17 -08:00
|
|
|
|
|
2017-03-12 15:06:34 -07:00
|
|
|
|
Console.WriteLine(result.Diagram());
|
|
|
|
|
|
2017-04-14 10:27:24 -07:00
|
|
|
|
if (result.UnparsedTokens.Any())
|
|
|
|
|
{
|
2017-04-12 16:03:45 -07:00
|
|
|
|
Console.WriteLine("Unparsed Tokens: ");
|
2017-04-14 10:27:24 -07:00
|
|
|
|
Console.WriteLine(string.Join(" ", result.UnparsedTokens));
|
2017-04-12 16:03:45 -07:00
|
|
|
|
}
|
|
|
|
|
|
2017-03-23 16:40:43 -07:00
|
|
|
|
var optionValuesToBeForwarded = result.AppliedCommand()
|
|
|
|
|
.OptionValuesToBeForwarded();
|
|
|
|
|
if (optionValuesToBeForwarded.Any())
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine("Option values to be forwarded: ");
|
|
|
|
|
Console.WriteLine(string.Join(" ", optionValuesToBeForwarded));
|
|
|
|
|
}
|
2017-03-12 15:06:34 -07:00
|
|
|
|
if (result.Errors.Any())
|
|
|
|
|
{
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
Console.WriteLine("ERRORS");
|
|
|
|
|
Console.WriteLine();
|
|
|
|
|
foreach (var error in result.Errors)
|
|
|
|
|
{
|
2017-03-22 13:51:32 -07:00
|
|
|
|
Console.WriteLine($"[{error?.Option?.Name ?? "???"}] {error?.Message}");
|
2017-03-12 15:06:34 -07:00
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-09 10:53:17 -08:00
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|