forked from dotnet/command-line-api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
43 lines (36 loc) · 1.47 KB
/
Program.cs
File metadata and controls
43 lines (36 loc) · 1.47 KB
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
42
43
// Copyright (c) .NET Foundation and contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System.IO;
using System.Linq;
using System.Threading.Tasks;
namespace System.CommandLine.Suggest
{
public class Program
{
internal static string DOTNET_SUGGEST_LOGGING = nameof(DOTNET_SUGGEST_LOGGING);
public static async Task<int> Main(string[] args)
{
#if DEBUG
LogDebug(new[] { "dotnet-suggest received: " }.Concat(args).ToArray());
#endif
var provider = new CombineSuggestionRegistration(
new GlobalToolsSuggestionRegistration(),
new FileSuggestionRegistration());
var dispatcher = new SuggestionDispatcher(provider);
return await dispatcher.InvokeAsync(args);
}
#if DEBUG
internal static void LogDebug(params string[] args)
{
if (Environment.GetEnvironmentVariable(DOTNET_SUGGEST_LOGGING) == "1")
{
var appData = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
var dotnetSuggestFolder = Path.Combine(appData, "dotnet-suggest");
Directory.CreateDirectory(dotnetSuggestFolder);
var logFile = Path.Combine(dotnetSuggestFolder, "debug.log");
File.AppendAllText(logFile, string.Join("|", args) + Environment.NewLine);
}
}
#endif
}
}