Skip to content

Commit

Permalink
add spectre.console to format the output
Browse files Browse the repository at this point in the history
  • Loading branch information
wooly905 committed Nov 18, 2024
1 parent ceee073 commit acd7d0c
Show file tree
Hide file tree
Showing 31 changed files with 1,102 additions and 1,171 deletions.
2 changes: 1 addition & 1 deletion PRS.sln
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.31424.327
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PRS", "PRS\PRS.csproj", "{DFB0A86C-13B4-4ECC-ACDD-207DC5783852}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PRS", "src\PRS.csproj", "{DFB0A86C-13B4-4ECC-ACDD-207DC5783852}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
69 changes: 0 additions & 69 deletions PRS/Commands/CommandHelper.cs

This file was deleted.

8 changes: 0 additions & 8 deletions PRS/Display/IDisplay.cs

This file was deleted.

19 changes: 0 additions & 19 deletions PRS/Display/LcdMonitor.cs

This file was deleted.

29 changes: 0 additions & 29 deletions PRS/FileHandle/SchemaFileReader.cs

This file was deleted.

43 changes: 43 additions & 0 deletions src/Commands/CommandHelper.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using PRS.Database;
using PRS.Display;
using PRS.FileHandle;

namespace PRS.Commands;

internal static class CommandHelper
{
public static async Task<string> GetConnectionStringAsync(IDisplay display, IFileProvider fileProvider)
{
if (!File.Exists(Global.ConnectionStringFilePath))
{
display.ShowError("Connection string doesn't exist. Please set it first.");
return string.Empty;
}

IFileReader reader = fileProvider.GetFileReader(Global.ConnectionStringFilePath);
string output = await reader.ReadLineAsync();
reader.Dispose();

return output;
}

public static void PrintColumns(IEnumerable<ColumnModel> models, IDisplay display)
{
display.DisplayColumns(models);
}

public static void PrintTables(IEnumerable<TableModel> models, IDisplay display)
{
display.DisplayTables(models);
}

public static void PrintModel(IEnumerable<string> models, IDisplay display)
{
display.ShowInfo("Name ===");

foreach (string m in models)
{
display.ShowInfo(m);
}
}
}
133 changes: 66 additions & 67 deletions PRS/Commands/CommandProvider.cs → src/Commands/CommandProvider.cs
Original file line number Diff line number Diff line change
@@ -1,67 +1,66 @@
using System;
using PRS.Database;
using PRS.Display;
using PRS.FileHandle;

namespace PRS.Commands;

internal static class CommandProvider
{
public static bool TryGetProvider(string input,
IDisplay display,
IDatabase database,
IFileProvider fileProvider,
out ICommand command)
{
if (string.Equals(input, "scs", StringComparison.OrdinalIgnoreCase))
{
command = new ShowConnectionStringCommand(display, fileProvider);
return true;
}

if (string.Equals(input, "wcs", StringComparison.OrdinalIgnoreCase))
{
command = new WriteConnectionStringCommand(display, fileProvider);
return true;
}

if (string.Equals(input, "dds", StringComparison.OrdinalIgnoreCase))
{
command = new DumpDatabaseSchemaCommand(display, database, fileProvider);
return true;
}

if (string.Equals(input, "ft", StringComparison.OrdinalIgnoreCase))
{
command = new FindTableCommand(display, fileProvider);
return true;
}

if (string.Equals(input, "fc", StringComparison.OrdinalIgnoreCase))
{
command = new FindColumnCommand(display, fileProvider);
return true;
}

if (string.Equals(input, "ftc", StringComparison.OrdinalIgnoreCase))
{
command = new FindTableColumnCommand(display, fileProvider);
return true;
}

if (string.Equals(input, "fsp", StringComparison.OrdinalIgnoreCase))
{
command = new FindStoredProcedureCommand(display, fileProvider);
return true;
}

if (string.Equals(input, "sc", StringComparison.OrdinalIgnoreCase))
{
command = new ShowAllColumnsCommand(display, fileProvider);
return true;
}

command = null;
return false;
}
}
using PRS.Database;
using PRS.Display;
using PRS.FileHandle;

namespace PRS.Commands;

internal static class CommandProvider
{
public static bool TryGetProvider(string input,
IDisplay display,
IDatabase database,
IFileProvider fileProvider,
out ICommand command)
{
if (string.Equals(input, "scs", StringComparison.OrdinalIgnoreCase))
{
command = new ShowConnectionStringCommand(display, fileProvider);
return true;
}

if (string.Equals(input, "wcs", StringComparison.OrdinalIgnoreCase))
{
command = new WriteConnectionStringCommand(display, fileProvider);
return true;
}

if (string.Equals(input, "dds", StringComparison.OrdinalIgnoreCase))
{
command = new DumpDatabaseSchemaCommand(display, database, fileProvider);
return true;
}

if (string.Equals(input, "ft", StringComparison.OrdinalIgnoreCase))
{
command = new FindTableCommand(display, fileProvider);
return true;
}

if (string.Equals(input, "fc", StringComparison.OrdinalIgnoreCase))
{
command = new FindColumnCommand(display, fileProvider);
return true;
}

if (string.Equals(input, "ftc", StringComparison.OrdinalIgnoreCase))
{
command = new FindTableColumnCommand(display, fileProvider);
return true;
}

if (string.Equals(input, "fsp", StringComparison.OrdinalIgnoreCase))
{
command = new FindStoredProcedureCommand(display, fileProvider);
return true;
}

if (string.Equals(input, "sc", StringComparison.OrdinalIgnoreCase))
{
command = new ShowAllColumnsCommand(display, fileProvider);
return true;
}

command = null;
return false;
}
}
Loading

0 comments on commit acd7d0c

Please sign in to comment.