-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add spectre.console to format the output
- Loading branch information
Showing
31 changed files
with
1,102 additions
and
1,171 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
133
PRS/Commands/CommandProvider.cs → src/Commands/CommandProvider.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
Oops, something went wrong.