Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/4130 disable color output for cli #4785

Merged
merged 3 commits into from
Dec 28, 2022

Conversation

damian-orzechowski
Copy link
Contributor

Closes #4130

Changes:

  • Nethermind.Cli will now not use color console output (using Colorful.Console package). Color output is still available using commandline switch -colorScheme with 2 options to choose: Basic and Dracula. Dracula color scheme was applied by default before this change.

Types of changes

What types of changes does your code introduce?
Put an x in the boxes that apply

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update
  • Code style update (formatting, renaming)
  • Refactoring (no functional changes, no api changes)
  • Build related changes
  • Other (please describe):

Testing

Requires testing

  • Yes
  • No

In case you checked yes, did you write tests??

  • Yes
  • No

Comments about testing , should you have some (optional)
Tested manually using Windows cmd, Windows terminal and bash on Ubuntu.

Further comments (optional)

It's worth to note that using different terminals may result in applying different colors when using colorScheme parameter. This is due to specific .Net console implementation (indexed colors) as well as Colorful.Console package implementation trying to find closest color in RGB space. None of these exiting behaviours is modified as a part of this change, but the ability to disable color output by default should help when you encounter issues using your favourite terminal.


private static readonly CliModuleLoader ModuleLoader = new CliModuleLoader(Engine, NodeManager, CliConsole);
var colorSchemeOption = app.Option("-cs|--colorScheme <colorScheme>", "Color Scheme. Possible values: Basic|Dracula", CommandOptionType.SingleValue);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP: cliColorScheme instead of colorScheme.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nevermind, this is for CLI anyway.

? new ColorfulCliConsole(cs)
: new CliConsole();

var historyManager = new StatementHistoryManager(cliConsole);
Copy link
Contributor

@asdacap asdacap Nov 29, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP: Inconsistent use of var or explicit type. I personally prefer var, but intellij seems to like explicit type better, which seems to be the main convention in Nethermind. In any case, please be consistent within the same file.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, I'm used to using var, but I'll adjust to convention.

}

private static void TestConnection()
private static void TestConnection(INodeManager nodeManager, ICliEngine cliEngine, ICliConsole cliConsole)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NP: please refrain from refactoring at the same time. Side note, I'd prefer previous style in this case.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure what you mean in this instance - is it the use od static fields instead of method params? If so, I feel this is a part of the change as the cliConsole and items which depend on it are now derived during runtime.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can also change just the static CliConsole and that would require less change. Of course, static var here is also not very nice. In any case, its not a breaking change.

@LukaszRozmej LukaszRozmej merged commit f556e04 into master Dec 28, 2022
@LukaszRozmej LukaszRozmej deleted the fix/4130_disable_color_output_for_Cli branch December 28, 2022 11:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Disable color-output of Nethermind.Cli per default
3 participants