-
-
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.
Separate CLI helpers into static class
- Loading branch information
Showing
2 changed files
with
49 additions
and
44 deletions.
There are no files selected for viewing
37 changes: 37 additions & 0 deletions
37
src/Riverside.JsonBinder.Console/Helpers/ConsoleHelpers.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 |
---|---|---|
@@ -0,0 +1,37 @@ | ||
namespace Riverside.JsonBinder.Console.Helpers; | ||
|
||
public static class ConsoleHelpers | ||
Check warning on line 3 in src/Riverside.JsonBinder.Console/Helpers/ConsoleHelpers.cs
|
||
{ | ||
/// <summary> | ||
/// Displays an error message with the specified title and details. | ||
/// </summary> | ||
/// <param name="title">The title of the error.</param> | ||
/// <param name="details">The details of the error.</param> | ||
public static void DisplayError(string title, string details) | ||
{ | ||
DisplayRedMessage($"\nError: {title}", false); | ||
DisplayRedMessage($"Details: {details}\n"); | ||
} | ||
|
||
/// <summary> | ||
/// Displays a message in red color. | ||
/// </summary> | ||
/// <param name="message">The message to display.</param> | ||
/// <param name="colorResets">Indicates whether to reset the color after displaying the message.</param> | ||
public static void DisplayRedMessage(string message, bool? colorResets = true) | ||
{ | ||
System.Console.ForegroundColor = ConsoleColor.Red; | ||
System.Console.WriteLine(message); | ||
if (colorResets is true) | ||
System.Console.ResetColor(); | ||
} | ||
|
||
/// <summary> | ||
/// Displays a "Press any key to continue" message and waits for input. | ||
/// </summary> | ||
public static void PressAnyKey() | ||
{ | ||
System.Console.WriteLine("\nPress any key to continue..."); | ||
System.Console.ReadKey(); | ||
} | ||
} |
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