Skip to content

Commit

Permalink
Fixed typo in EventDbTool and cleaned up unused usings and formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jschick04 authored and bill-long committed Nov 11, 2024
1 parent 3d03dbf commit 2f4802e
Show file tree
Hide file tree
Showing 8 changed files with 22 additions and 52 deletions.
6 changes: 1 addition & 5 deletions src/EventLogExpert.EventDbTool/CreateDatabaseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,7 @@ public static Command GetCommand()
createDatabaseCommand.AddOption(filterOption);
createDatabaseCommand.AddOption(skipProvidersInFileOption);
createDatabaseCommand.AddOption(verboseOption);
createDatabaseCommand.SetHandler((fileOptionValue, filterOptionValue, verboseOptionValue, skipProvidersInFileOption) =>
{
CreateDatabase(fileOptionValue, filterOptionValue, verboseOptionValue, skipProvidersInFileOption);
},
fileArgument, filterOption, verboseOption, skipProvidersInFileOption);
createDatabaseCommand.SetHandler(CreateDatabase, fileArgument, filterOption, verboseOption, skipProvidersInFileOption);

return createDatabaseCommand;
}
Expand Down
12 changes: 6 additions & 6 deletions src/EventLogExpert.EventDbTool/DbToolCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace EventLogExpert.EventDbTool;

public class DbToolCommand
{
private static string _providerDetailFormat = "{0, -14} {1, 8} {2, 8} {3, 8} {4, 8} {5, 8}";
private static string s_providerDetailFormat = "{0, -14} {1, 8} {2, 8} {3, 8} {4, 8} {5, 8}";

public static List<string> GetLocalProviderNames(string filter)
{
Expand All @@ -28,20 +28,20 @@ public static void LogProviderDetailHeader(IEnumerable<string> providerNames)
{
var maxNameLength = providerNames.Any() ? providerNames.Max(p => p.Length) : 14;
if (maxNameLength < 14) maxNameLength = 14;
_providerDetailFormat = "{0, -" + maxNameLength + "} {1, 8} {2, 8} {3, 8} {4, 8} {5, 8} {6, 8}";
Console.WriteLine(string.Format(_providerDetailFormat, "Provider Name", "Events", "Parameters", "Keywords", "Opcodes", "Tasks", "Messages"));
s_providerDetailFormat = "{0, -" + maxNameLength + "} {1, 8} {2, 8} {3, 8} {4, 8} {5, 8} {6, 8}";
Console.WriteLine(s_providerDetailFormat, "Provider Name", "Events", "Parameters", "Keywords", "Opcodes", "Tasks", "Messages");
}

public static void LogProviderDetails(ProviderDetails details)
{
Console.WriteLine(string.Format(
_providerDetailFormat,
Console.WriteLine(
s_providerDetailFormat,
details.ProviderName,
details.Events.Count,
details.Parameters.Count,
details.Keywords.Count,
details.Opcodes.Count,
details.Tasks.Count,
details.Messages.Count));
details.Messages.Count);
}
}
20 changes: 8 additions & 12 deletions src/EventLogExpert.EventDbTool/DiffDatabaseCommand.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// // Copyright (c) Microsoft Corporation.
// // Licensed under the MIT License.

using EventLogExpert.Eventing.Providers;
using EventLogExpert.Eventing.EventProviderDatabase;
using EventLogExpert.Eventing.Providers;
using System.CommandLine;

namespace EventLogExpert.EventDbTool;
Expand All @@ -11,7 +11,7 @@ public class DiffDatabaseCommand : DbToolCommand
{
public static Command GetCommand()
{
var diffDatababaseCommand = new Command(
var diffDatabaseCommand = new Command(
name: "diff",
description: "Given two databases, produces a third database containing all providers " +
"from the second database which are not in the first database.");
Expand All @@ -27,17 +27,13 @@ public static Command GetCommand()
var verboseOption = new Option<bool>(
name: "--verbose",
description: "Verbose logging. May be useful for troubleshooting.");
diffDatababaseCommand.AddArgument(dbOneArgument);
diffDatababaseCommand.AddArgument(dbTwoArgument);
diffDatababaseCommand.AddArgument(newDbArgument);
diffDatababaseCommand.AddOption(verboseOption);
diffDatababaseCommand.SetHandler((dbOneArgValue, dbTwoArgValue, newDbArgValue, verboseOptionValue) =>
{
DiffDatabase(dbOneArgValue, dbTwoArgValue, newDbArgValue, verboseOptionValue);
},
dbOneArgument, dbTwoArgument, newDbArgument, verboseOption);
diffDatabaseCommand.AddArgument(dbOneArgument);
diffDatabaseCommand.AddArgument(dbTwoArgument);
diffDatabaseCommand.AddArgument(newDbArgument);
diffDatabaseCommand.AddOption(verboseOption);
diffDatabaseCommand.SetHandler(DiffDatabase, dbOneArgument, dbTwoArgument, newDbArgument, verboseOption);

return diffDatababaseCommand;
return diffDatabaseCommand;
}

public static void DiffDatabase(string dbOne, string dbTwo, string newDb, bool verbose)
Expand Down
8 changes: 2 additions & 6 deletions src/EventLogExpert.EventDbTool/MergeDatabaseCommand.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// // Copyright (c) Microsoft Corporation.
// // Licensed under the MIT License.

using EventLogExpert.Eventing.Providers;
using EventLogExpert.Eventing.EventProviderDatabase;
using EventLogExpert.Eventing.Providers;
using System.CommandLine;

namespace EventLogExpert.EventDbTool;
Expand Down Expand Up @@ -31,11 +31,7 @@ public static Command GetCommand()
mergeDatabaseCommand.AddArgument(targetDatabaseArgument);
mergeDatabaseCommand.AddOption(overwriteOption);
mergeDatabaseCommand.AddOption(verboseOption);
mergeDatabaseCommand.SetHandler((sourceArgumentValue, targetArgumentValue, overwriteOptionValue, verboseOptionValue) =>
{
MergeDatabase(sourceArgumentValue, targetArgumentValue, overwriteOptionValue, verboseOptionValue);
},
sourceDatabaseArgument, targetDatabaseArgument, overwriteOption, verboseOption);
mergeDatabaseCommand.SetHandler(MergeDatabase, sourceDatabaseArgument, targetDatabaseArgument, overwriteOption, verboseOption);

return mergeDatabaseCommand;
}
Expand Down
4 changes: 2 additions & 2 deletions src/EventLogExpert.EventDbTool/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@

namespace EventLogExpert.EventDbTool;

class Program
internal class Program
{
static async Task<int> Main(string[] args)
private static async Task<int> Main(string[] args)
{
var rootCommand = new RootCommand("Tool used to create and modify databases for use with EventLogExpert");

Expand Down
12 changes: 1 addition & 11 deletions src/EventLogExpert.EventDbTool/ShowDatabaseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,8 @@
// // Licensed under the MIT License.

using EventLogExpert.Eventing.EventProviderDatabase;
using EventLogExpert.Eventing.Providers;
using System;
using System.Collections.Generic;
using System.CommandLine;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace EventLogExpert.EventDbTool;

Expand All @@ -32,11 +26,7 @@ public static Command GetCommand()
showDatabaseCommand.AddArgument(fileArgument);
showDatabaseCommand.AddOption(filterOption);
showDatabaseCommand.AddOption(verboseOption);
showDatabaseCommand.SetHandler((fileArgumentValue, filterOptionValue, verboseOptionValue) =>
{
ShowProviderInfo(fileArgumentValue, filterOptionValue, verboseOptionValue);
},
fileArgument, filterOption, verboseOption);
showDatabaseCommand.SetHandler(ShowProviderInfo, fileArgument, filterOption, verboseOption);

return showDatabaseCommand;
}
Expand Down
6 changes: 1 addition & 5 deletions src/EventLogExpert.EventDbTool/ShowLocalCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ public static Command GetCommand()
description: "Verbose logging. May be useful for troubleshooting.");
showProvidersCommand.AddOption(filterOption);
showProvidersCommand.AddOption(verboseOption);
showProvidersCommand.SetHandler((filterOptionValue, verboseOptionValue) =>
{
ShowProviderInfo(filterOptionValue, verboseOptionValue);
},
filterOption, verboseOption);
showProvidersCommand.SetHandler(ShowProviderInfo, filterOption, verboseOption);

return showProvidersCommand;
}
Expand Down
6 changes: 1 addition & 5 deletions src/EventLogExpert.EventDbTool/UpgradeDatabaseCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ public static Command GetCommand()
description: "Verbose logging. May be useful for troubleshooting.");
upgradeDatabaseCommand.AddArgument(fileArgument);
upgradeDatabaseCommand.AddOption(verboseOption);
upgradeDatabaseCommand.SetHandler((fileArgumentValue, verboseOptionValue) =>
{
UpgradeDatabase(fileArgumentValue, verboseOptionValue);
},
fileArgument, verboseOption);
upgradeDatabaseCommand.SetHandler(UpgradeDatabase, fileArgument, verboseOption);

return upgradeDatabaseCommand;
}
Expand Down

0 comments on commit 2f4802e

Please sign in to comment.