-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
print parameter value if and only if provided via CLI arg or config (#…
…464) Follow up to #463 As per Zoom discussion, BMX will always print parameter value & source if and only if it's provided via CLI args or config file. I also made it colourful for legibility. The line seems too long and crowded without these colours. ![image](https://github.com/user-attachments/assets/27461fa6-2b9a-48a1-946e-5db92d244235) The colours don't work if stdout is redirected, which is typical when using `bmx print`. I know why this is happening. Will try to fix in a separate PR. https://desire2learn.atlassian.net/browse/VUL-423
- Loading branch information
Showing
8 changed files
with
84 additions
and
20 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 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 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,17 @@ | ||
namespace D2L.Bmx; | ||
|
||
internal interface IConsoleWriter { | ||
void WriteParameter( string description, string value, ParameterSource source ); | ||
} | ||
|
||
internal class ConsoleWriter : IConsoleWriter { | ||
void IConsoleWriter.WriteParameter( string description, string value, ParameterSource source ) { | ||
Console.ResetColor(); | ||
Console.Error.Write( $"{description}: " ); | ||
Console.ForegroundColor = ConsoleColor.Cyan; | ||
Console.Error.Write( value ); | ||
Console.ForegroundColor = ConsoleColor.DarkGray; | ||
Console.Error.WriteLine( $" (from {source})" ); | ||
Console.ResetColor(); | ||
} | ||
} |
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 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 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,14 @@ | ||
namespace D2L.Bmx; | ||
|
||
internal record ParameterSource { | ||
public string Description { get; init; } | ||
|
||
private ParameterSource( string description ) { | ||
Description = description; | ||
} | ||
|
||
public static ParameterSource CliArg => new( "command line argument" ); | ||
public static ParameterSource Config => new( "config file" ); | ||
|
||
public override string ToString() => Description; | ||
} |
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 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