// The .NET Foundation licenses this file to you under the MIT license.
using System.CommandLine;
+using System.CommandLine.Builder;
using System.CommandLine.Invocation;
-namespace Microsoft.Tools.Common
+namespace Microsoft.Internal.Common
{
- public static class CommandExtenions
+ public static class CommandExtensions
{
/// <summary>
/// Allows the command handler to be included in the collection initializer.
{
command.Handler = handler;
}
+
+ /// <summary>
+ /// Setups the diagnostic tools defaults. Like .UseDefault except RegisterWithDotnetSuggest() which
+ /// causes problems on Linux systems with R/O /tmp directory.
+ /// </summary>
+ public static CommandLineBuilder UseToolsDefaults(this CommandLineBuilder builder)
+ {
+ return builder
+ .UseVersionOption()
+ .UseHelp()
+ .UseEnvironmentVariableDirective()
+ .UseParseDirective()
+ .UseDebugDirective()
+ .UseSuggestDirective()
+ .UseTypoCorrections()
+ .UseParseErrorReporting()
+ .UseExceptionHandler()
+ .CancelOnProcessTermination();
+ }
}
}
using System.Text;
using Microsoft.Diagnostics.NETCore.Client;
using Microsoft.Internal.Common.Utils;
-using Microsoft.Tools.Common;
+using Microsoft.Internal.Common;
using Process = System.Diagnostics.Process;
namespace Microsoft.Internal.Common.Commands
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.Internal.Common;
using Microsoft.Internal.Common.Commands;
using Microsoft.Internal.Common.Utils;
-using Microsoft.Tools.Common;
namespace Microsoft.Diagnostics.Tools.Counters
{
.AddCommand(CollectCommand())
.AddCommand(ListCommand())
.AddCommand(ProcessStatusCommandHandler.ProcessStatusCommand("Lists the dotnet processes that can be monitored."))
- .UseDefaults()
+ .UseToolsDefaults()
.Build();
ParseResult parseResult = parser.Parse(args);
using System.CommandLine.Parsing;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.Internal.Common;
using Microsoft.Internal.Common.Utils;
-using Microsoft.Tools.Common;
namespace Microsoft.Diagnostics.Tools.DiagnosticsServerRouter
{
.AddCommand(IOSRouterCommand())
.AddCommand(AndroidEmulatorRouterCommand())
.AddCommand(AndroidRouterCommand())
- .UseDefaults()
+ .UseToolsDefaults()
.Build();
ParseResult parseResult = parser.Parse(args);
using System.CommandLine.Parsing;
using System.IO;
using System.Threading.Tasks;
+using Microsoft.Internal.Common;
using Microsoft.Internal.Common.Commands;
-using Microsoft.Tools.Common;
namespace Microsoft.Diagnostics.Tools.Dump
{
.AddCommand(CollectCommand())
.AddCommand(AnalyzeCommand())
.AddCommand(ProcessStatusCommandHandler.ProcessStatusCommand("Lists the dotnet processes that dumps can be collected from."))
- .UseDefaults()
+ .UseToolsDefaults()
.Build();
return parser.InvokeAsync(args);
using System.Threading.Tasks;
using Graphs;
using Microsoft.Diagnostics.NETCore.Client;
+using Microsoft.Internal.Common;
using Microsoft.Internal.Common.Utils;
-using Microsoft.Tools.Common;
namespace Microsoft.Diagnostics.Tools.GCDump
{
using System.CommandLine;
using System.IO;
using Graphs;
-using Microsoft.Tools.Common;
+using Microsoft.Internal.Common;
namespace Microsoft.Diagnostics.Tools.GCDump
{
using System.IO;
using System.Threading;
using System.Threading.Tasks;
+using Microsoft.Diagnostics.NETCore.Client;
using Microsoft.Diagnostics.Tools.GCDump.CommandLine;
-using Microsoft.Tools.Common;
+using Microsoft.Internal.Common;
using Microsoft.Internal.Common.Utils;
-using Microsoft.Diagnostics.NETCore.Client;
namespace Microsoft.Diagnostics.Tools.GCDump
{
using System.CommandLine.Builder;
using System.CommandLine.Parsing;
using System.Threading.Tasks;
+using Microsoft.Internal.Common;
using Microsoft.Internal.Common.Commands;
namespace Microsoft.Diagnostics.Tools.GCDump
.AddCommand(ProcessStatusCommandHandler.ProcessStatusCommand("Lists the dotnet processes that gcdumps can be collected from."))
.AddCommand(ReportCommandHandler.ReportCommand())
.AddCommand(ConvertCommandHandler.ConvertCommand())
- .UseDefaults()
+ .UseToolsDefaults()
.Build();
return parser.InvokeAsync(args);
using System.CommandLine.Parsing;
using System.Runtime.InteropServices;
using System.Threading.Tasks;
-using Microsoft.Tools.Common;
+using Microsoft.Internal.Common;
using SOS;
namespace Microsoft.Diagnostics.Tools.SOS
Parser parser = new CommandLineBuilder()
.AddCommand(InstallCommand())
.AddCommand(UninstallCommand())
- .UseDefaults()
+ .UseToolsDefaults()
.Build();
return parser.InvokeAsync(args);
using System.CommandLine.Builder;
using System.CommandLine.Parsing;
using System.Threading.Tasks;
+using Microsoft.Internal.Common;
using Microsoft.Internal.Common.Commands;
namespace Microsoft.Diagnostics.Tools.Stack
.AddCommand(ReportCommandHandler.ReportCommand())
.AddCommand(ProcessStatusCommandHandler.ProcessStatusCommand("Lists the dotnet processes that stack traces can be collected from."))
.AddCommand(SymbolicateHandler.SymbolicateCommand())
- .UseDefaults()
+ .UseToolsDefaults()
.Build();
return parser.InvokeAsync(args);
using Microsoft.Diagnostics.Tracing;
using Microsoft.Diagnostics.Tracing.Etlx;
using Microsoft.Diagnostics.Tracing.Stacks;
+using Microsoft.Internal.Common;
using Microsoft.Internal.Common.Utils;
-using Microsoft.Tools.Common;
namespace Microsoft.Diagnostics.Tools.Stack
{
using System.Reflection.Metadata.Ecma335;
using System.Reflection.PortableExecutable;
using System.Text.RegularExpressions;
-using Microsoft.Tools.Common;
+using Microsoft.Internal.Common;
namespace Microsoft.Diagnostics.Tools.Stack
{
using System.Threading.Tasks;
using Microsoft.Diagnostics.Monitoring.EventPipe;
using Microsoft.Diagnostics.NETCore.Client;
+using Microsoft.Internal.Common;
using Microsoft.Internal.Common.Utils;
-using Microsoft.Tools.Common;
namespace Microsoft.Diagnostics.Tools.Trace
{
using System.CommandLine.IO;
using System.IO;
using System.Linq;
-using Microsoft.Tools.Common;
+using Microsoft.Internal.Common;
namespace Microsoft.Diagnostics.Tools.Trace
{
using Microsoft.Diagnostics.Tracing;
using Microsoft.Diagnostics.Tracing.Etlx;
using Microsoft.Diagnostics.Tracing.Stacks;
-using Microsoft.Tools.Common;
+using Microsoft.Internal.Common;
namespace Microsoft.Diagnostics.Tools.Trace
{
using System.CommandLine.Builder;
using System.CommandLine.Parsing;
using System.Threading.Tasks;
+using Microsoft.Internal.Common;
using Microsoft.Internal.Common.Commands;
using Microsoft.Internal.Common.Utils;
.AddCommand(ListProfilesCommandHandler.ListProfilesCommand())
.AddCommand(ConvertCommandHandler.ConvertCommand())
.AddCommand(ReportCommandHandler.ReportCommand())
- .UseDefaults()
+ .UseToolsDefaults()
.Build();
ParseResult parseResult = parser.Parse(args);
string parsedCommandName = parseResult.CommandResult.Command.Name;