mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-02-16 18:47:57 -05:00
Add developers startup arg (#997)
This commit is contained in:
@@ -22,6 +22,8 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Construct and parse command line options from the arguments array
|
/// Construct and parse command line options from the arguments array
|
||||||
/// </summary>
|
/// </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)
|
public CommandOptions(string[] args, string serviceName)
|
||||||
{
|
{
|
||||||
ServiceName = serviceName;
|
ServiceName = serviceName;
|
||||||
@@ -89,7 +91,7 @@ namespace Microsoft.SqlTools.Hosting.Utility
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Whether the program should exit immediately. Set to true when the usage is printed.
|
/// Whether the program should exit immediately. Set to true when the usage is printed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public bool ShouldExit { get; private set; }
|
public bool ShouldExit { get; protected set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The locale our we should instantiate this service in
|
/// The locale our we should instantiate this service in
|
||||||
|
|||||||
@@ -70,14 +70,14 @@ namespace Microsoft.SqlTools.Utility
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static void Flush()
|
public static void Flush()
|
||||||
{
|
{
|
||||||
TraceSource.Flush();
|
TraceSource?.Flush();
|
||||||
Trace.Flush();
|
Trace.Flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Close()
|
public static void Close()
|
||||||
{
|
{
|
||||||
Flush();
|
Flush();
|
||||||
TraceSource.Close();
|
TraceSource?.Close();
|
||||||
Trace.Close();
|
Trace.Close();
|
||||||
Listener = null; // Since we have closed the listener, set listener to null.
|
Listener = null; // Since we have closed the listener, set listener to null.
|
||||||
}
|
}
|
||||||
@@ -86,8 +86,11 @@ namespace Microsoft.SqlTools.Utility
|
|||||||
get => tracingLevel;
|
get => tracingLevel;
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
// configures the source level filter. This alone is not enough for tracing that is done via "Trace" class instead of "TraceSource" object
|
if(TraceSource != null)
|
||||||
TraceSource.Switch = new SourceSwitch(TraceSource.Name, value.ToString());
|
{
|
||||||
|
// 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
|
// configure the listener level filter
|
||||||
tracingLevel = value;
|
tracingLevel = value;
|
||||||
Listener.Filter = new EventTypeFilter(tracingLevel);
|
Listener.Filter = new EventTypeFilter(tracingLevel);
|
||||||
@@ -216,8 +219,8 @@ namespace Microsoft.SqlTools.Utility
|
|||||||
TraceOutputOptions = TraceOptions.DateTime | TraceOptions.ProcessId | TraceOptions.ThreadId,
|
TraceOutputOptions = TraceOptions.DateTime | TraceOptions.ProcessId | TraceOptions.ThreadId,
|
||||||
Filter = new EventTypeFilter(TracingLevel),
|
Filter = new EventTypeFilter(TracingLevel),
|
||||||
};
|
};
|
||||||
TraceSource.Listeners.Clear();
|
TraceSource?.Listeners.Clear();
|
||||||
TraceSource.Listeners.Add(Listener);
|
TraceSource?.Listeners.Add(Listener);
|
||||||
Trace.Listeners.Clear();
|
Trace.Listeners.Clear();
|
||||||
Trace.Listeners.Add(Listener);
|
Trace.Listeners.Add(Listener);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,7 +2,9 @@
|
|||||||
// Copyright (c) Microsoft. All rights reserved.
|
// Copyright (c) Microsoft. All rights reserved.
|
||||||
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
|
using System.Linq;
|
||||||
using Microsoft.SqlTools.Hosting.Utility;
|
using Microsoft.SqlTools.Hosting.Utility;
|
||||||
|
|
||||||
namespace Microsoft.SqlTools.ServiceLayer.Utility
|
namespace Microsoft.SqlTools.ServiceLayer.Utility
|
||||||
@@ -11,8 +13,36 @@ namespace Microsoft.SqlTools.ServiceLayer.Utility
|
|||||||
{
|
{
|
||||||
internal const string ServiceLayerServiceName = "MicrosoftSqlToolsServiceLayer.exe";
|
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)
|
public override void SetLocale(string locale)
|
||||||
|
|||||||
Reference in New Issue
Block a user