feat(rust): add syntax highlighting to shell script examples #3364
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 theockam
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-addedhighlight
module and itsshell_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:
Solarized (dark):
Solarized (light):
base16-eighties.dark:
base16-mocha.dark:
base16-ocean.dark:
base16-ocean.light:
Let me know which theme suits best.
For my 2p it's
base16-mocha.dark
withbg
false.Checks