forked from dotnet/sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFormatCommand.cs
41 lines (33 loc) · 1.13 KB
/
FormatCommand.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System.CommandLine;
using Microsoft.DotNet.Cli;
using Microsoft.DotNet.Cli.Extensions;
using Microsoft.DotNet.Cli.Utils;
namespace Microsoft.DotNet.Tools.Format;
public class FormatCommand : DotnetFormatForwardingApp
{
public FormatCommand(IEnumerable<string> argsToForward) : base(argsToForward)
{
}
public static FormatCommand FromArgs(string[] args)
{
var parser = Parser.Instance;
var result = parser.ParseFrom("dotnet format", args);
return FromParseResult(result);
}
public static FormatCommand FromParseResult(ParseResult result)
{
return new FormatCommand(result.GetValue(FormatCommandParser.Arguments));
}
public static int Run(ParseResult parseResult)
{
parseResult.HandleDebugSwitch();
return FromParseResult(parseResult).Execute();
}
public static int Run(string[] args)
{
DebugHelper.HandleDebugSwitch(ref args);
return new DotnetFormatForwardingApp(args).Execute();
}
}