mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-18 01:25:41 -05:00
Add developers startup arg (#997)
This commit is contained in:
@@ -22,6 +22,8 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
||||
/// <summary>
|
||||
/// Construct and parse command line options from the arguments array
|
||||
/// </summary>
|
||||
/// <param name="args">The args to parse</param>
|
||||
/// <param name="serviceName">Name of the service to display</param>
|
||||
public CommandOptions(string[] args, string serviceName)
|
||||
{
|
||||
ServiceName = serviceName;
|
||||
@@ -89,7 +91,7 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
||||
/// <summary>
|
||||
/// Whether the program should exit immediately. Set to true when the usage is printed.
|
||||
/// </summary>
|
||||
public bool ShouldExit { get; private set; }
|
||||
public bool ShouldExit { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// The locale our we should instantiate this service in
|
||||
|
||||
@@ -70,14 +70,14 @@ namespace Microsoft.SqlTools.Utility
|
||||
/// </summary>
|
||||
public static void Flush()
|
||||
{
|
||||
TraceSource.Flush();
|
||||
TraceSource?.Flush();
|
||||
Trace.Flush();
|
||||
}
|
||||
|
||||
public static void Close()
|
||||
{
|
||||
Flush();
|
||||
TraceSource.Close();
|
||||
TraceSource?.Close();
|
||||
Trace.Close();
|
||||
Listener = null; // Since we have closed the listener, set listener to null.
|
||||
}
|
||||
@@ -86,8 +86,11 @@ namespace Microsoft.SqlTools.Utility
|
||||
get => tracingLevel;
|
||||
set
|
||||
{
|
||||
// configures the source level filter. This alone is not enough for tracing that is done via "Trace" class instead of "TraceSource" object
|
||||
TraceSource.Switch = new SourceSwitch(TraceSource.Name, value.ToString());
|
||||
if(TraceSource != null)
|
||||
{
|
||||
// configures the source level filter. This alone is not enough for tracing that is done via "Trace" class instead of "TraceSource" object
|
||||
TraceSource.Switch = new SourceSwitch(TraceSource.Name, value.ToString());
|
||||
}
|
||||
// configure the listener level filter
|
||||
tracingLevel = value;
|
||||
Listener.Filter = new EventTypeFilter(tracingLevel);
|
||||
@@ -216,8 +219,8 @@ namespace Microsoft.SqlTools.Utility
|
||||
TraceOutputOptions = TraceOptions.DateTime | TraceOptions.ProcessId | TraceOptions.ThreadId,
|
||||
Filter = new EventTypeFilter(TracingLevel),
|
||||
};
|
||||
TraceSource.Listeners.Clear();
|
||||
TraceSource.Listeners.Add(Listener);
|
||||
TraceSource?.Listeners.Clear();
|
||||
TraceSource?.Listeners.Add(Listener);
|
||||
Trace.Listeners.Clear();
|
||||
Trace.Listeners.Add(Listener);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,9 @@
|
||||
// Copyright (c) Microsoft. All rights reserved.
|
||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||
|
||||
using System;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using Microsoft.SqlTools.Hosting.Utility;
|
||||
|
||||
namespace Microsoft.SqlTools.ServiceLayer.Utility
|
||||
@@ -11,8 +13,36 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
|
||||
{
|
||||
internal const string ServiceLayerServiceName = "MicrosoftSqlToolsServiceLayer.exe";
|
||||
|
||||
public ServiceLayerCommandOptions(string[] args) : base(args, ServiceLayerServiceName)
|
||||
private static readonly string[] serviceLayerCommandArgs = { "-d", "--developers" };
|
||||
|
||||
/**
|
||||
* List of contributors to this project, used as part of the onboarding process.
|
||||
*/
|
||||
private readonly string[] contributors = new string[] {
|
||||
// Put your Github username here!
|
||||
"Charles-Gagnon"
|
||||
};
|
||||
|
||||
public ServiceLayerCommandOptions(string[] args) : base(args.Where(arg => !serviceLayerCommandArgs.Contains(arg)).ToArray(), ServiceLayerServiceName)
|
||||
{
|
||||
for (int i = 0; i < args.Length; ++i)
|
||||
{
|
||||
string arg = args[i].ToLowerInvariant();
|
||||
|
||||
switch (arg)
|
||||
{
|
||||
case "-d":
|
||||
case "--developers":
|
||||
Console.WriteLine();
|
||||
Console.WriteLine("**********************************************************************************");
|
||||
Console.WriteLine("These are some of the developers who have contributed to this project - thank you!");
|
||||
Console.WriteLine("**********************************************************************************");
|
||||
Console.WriteLine();
|
||||
Console.WriteLine(string.Join(Environment.NewLine, contributors.Select(contributor => $"\t{contributor}")));
|
||||
this.ShouldExit = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override void SetLocale(string locale)
|
||||
|
||||
Reference in New Issue
Block a user