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

feat(rust): add syntax highlighting to shell script examples #3364

Merged
merged 1 commit into from
Aug 27, 2022
Merged

feat(rust): add syntax highlighting to shell script examples #3364

merged 1 commit into from
Aug 27, 2022

Conversation

jlucktay
Copy link
Contributor

@jlucktay jlucktay commented Aug 27, 2022

Current Behavior

Shell script examples in help messages are plain text and not styled at all.
Ref: #3311

Proposed Changes

Makes use of the syntect crate to run a syntax highlighting pass over the example shell scripts for the ockam command.

Setting this PR as a draft for this first pass as it only affects the base command and not any sub-commands yet, to see whether or not the implementation is a good fit for this project.

Details

I split const HELP_TEMPLATE: &str in half to make things a bit simpler in the newly-added highlight module and its shell_scripts function. Let me know if this looks OK and I can apply the same pattern across the other sub-commands.

Colour samples

These are the different themes available in the crate.
Each has the bg: bool flag toggled on and off for background highlighting.
Click for bigger images.

InspiredGitHub: sample of InspiredGitHub style

Solarized (dark): sample of Solarized (dark) style

Solarized (light): sample of Solarized (light) style

base16-eighties.dark: sample of base16-eighties.dark style

base16-mocha.dark: sample of base16-mocha.dark style

base16-ocean.dark: sample of base16-ocean.dark style

base16-ocean.light: sample of base16-ocean.light style

Let me know which theme suits best.
For my 2p it's base16-mocha.dark with bg false.

Checks

@mrinalwadhwa
Copy link
Member

@jlucktay this looks fantastic! congratulations on your first PR.
I think base16-mocha.dark with bg false looks quite good.

I tried various preset themes in iTerm to see how it would render for people and I think people with light backgrounds won't have a great experience. So I'm wondering if we can do something to improve that 🤔

Screen Shot 2022-08-27 at 9 08 10 AM

Screen Shot 2022-08-27 at 9 08 03 AM

Screen Shot 2022-08-27 at 9 07 56 AM

Screen Shot 2022-08-27 at 9 07 50 AM

Screen Shot 2022-08-27 at 9 07 43 AM

Screen Shot 2022-08-27 at 9 07 33 AM

Screen Shot 2022-08-27 at 9 07 26 AM

Screen Shot 2022-08-27 at 9 07 16 AM

Screen Shot 2022-08-27 at 9 07 07 AM

@mrinalwadhwa
Copy link
Member

I tried various preset themes in iTerm to see how it would render for people and I think people with light backgrounds won't have a great experience. So I'm wondering if we can do something to improve that 🤔

Wonder what other projects that render code on the terminal handle this.
Delta comes to mind as an example https://github.com/dandavison/delta

Makes use of the syntect crate to run a syntax highlighting pass over
the example shell scripts for the ockam command.

This first pass only affects the base command and not any sub-commands
yet, to see whether or not the implementation is a good fit for this
project.
@mrinalwadhwa mrinalwadhwa marked this pull request as ready for review August 27, 2022 19:05
@mrinalwadhwa mrinalwadhwa requested a review from a team as a code owner August 27, 2022 19:05
@mrinalwadhwa
Copy link
Member

mrinalwadhwa commented Aug 27, 2022

@jlucktay this is already very useful for some of the help improvements that I am working on today. So I hope you won't mind if I land right now. If you think of any further improvement, follow on PRs are very welcome!

Congratulation on an awesome first contribution 🥂

@mrinalwadhwa
Copy link
Member

Found a really nice article on adjusting color. Thank you @Canop 🙏
https://dystroy.org/blog/terminal-light/

@mergify mergify bot merged commit a1aa430 into build-trust:develop Aug 27, 2022
@Canop
Copy link

Canop commented Aug 28, 2022

Found a really nice article on adjusting color. Thank you @Canop pray https://dystroy.org/blog/terminal-light/

You're welcome. I'd be interested to see how you used it.

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.

3 participants