click-extra snippet - Highlight a source file and write it as an
image or HTML.
click-extra snippet [OPTIONS] SOURCE
Highlight a source file and write it as an image or HTML.
Colors SOURCE with Pygments, then draws it in the same window a
captured command is drawn in. Pass - to read the source from stdin, which
needs --language: there is no file name left to guess from.
click-extra snippet --output ripen.svg ripen.py
The window is painted the background the syntax style was designed
against, so a snippet looks like that theme does in an editor rather than
like the same theme dropped on a foreign surface.
Both formats are the screenshot command's:
- .svg: a picture, for a surface that strips inline HTML;
- .html: selectable, searchable, copy-pasteable text.
Highlighting needs the pygments extra.
- SOURCE
- --output
FILE
- Path of the file to write. Its extension picks the format: .svg for an
image, .html for selectable text, .ansi for the escape sequences
themselves. Pass - to print those to the terminal, which draws no window.
[required]
- --columns
[auto|INTEGER]
- Width, in characters, the image is laid out at. Pass auto to take the
longest line the source holds, so nothing folds: a file was never wrapped
to a terminal's width, and code that soft-wrapped in the picture would
lose the indentation a reader is there to read.
- --background
[dark|light]
- Terminal chrome the capture is drawn on, and the palette its colors
resolve against. Match it to the theme the captured CLI renders with: a
light-background theme washes out on the dark default.
- --preset
[linux|macos|plain|windows]
- Terminal to draw the capture as: its window decorations, palette, font and
prompt sigil. Anything stated alongside wins over it. Left out, the
capture keeps the renderer's own neutral window.
- --border
COLOR
- Color of the frame drawn around the terminal window, as CSS names it. Pass
none to draw no frame. Defaults to the one the chrome can show.
- --border-width
PIXELS
- Thickness of that frame, in pixels.
- --radius
PIXELS
- How round the window's corners are, in pixels. Zero squares them. Defaults
to 8, or to the rounding --preset terminal draws.
- --backdrop
COLOR
- Color filling the image behind the window, margin included, as CSS names
it. Left transparent by default, so the page shows through.
- --shadow
COLOR
- Color of the drop shadow lifting the window off the page, as CSS names it.
Pass none to draw no shadow. Defaults to the one the chrome calls
for.
- --margin
PIXELS
- Transparent pixels left around the window, on all four sides. The room the
drop shadow falls into, so a capture drawing one wants some.
- --padding
PIXELS
- Pixels added inside the window, around the drawn text, on top of the few
the renderer adds on its own.
- --opacity
FLOAT RANGE
- How solid the window's body is. Under 1 it turns see-through, the way a
terminal set to transparency does: whatever the capture sits on shows
through it, while its text, frame and title bar keep their own paint.
- --watermark
TEXT
- Credit line drawn in the image's bottom-right corner, in the margin around
the window. Pass an empty string to draw none, or your own text to credit
your project instead.
- --watermark-color
COLOR
- Color that credit line is drawn in, as CSS names it, alpha included.
Defaults to a neutral gray: the line sits in the transparent margin, so it
answers to the page embedding the image rather than to the chrome.
- --head INTEGER
RANGE
- Keep only the first N lines.
- --tail INTEGER
RANGE
- Keep only the last N lines.
- --truncation
TEXT
- Line standing in for what --head or --tail cut away.
- --line-numbers
- Number the drawn lines in a gutter, the way Pygments does inline. Line 1
is the first line the picture shows.
- --emphasize-lines
LINES
- Draw a band behind the lines named, as 2,4-5. Counted from 1 as the
picture draws them. Ranges are closed: state both ends.
- --title
TEXT
- Caption drawn in an SVG's window chrome, or an HTML document's title.
- --fragment
- For HTML, emit the bare block instead of a standalone document, to paste
into a page that has its own.
- --language
TEXT
- Language the source is highlighted as, as Pygments names it. Guessed from
the file name, then from the content, when left out. See
https://pygments.org/languages/ for the ones it knows.
- --syntax-style
STYLE
- Pygments style the source is colored with, which also paints the window: a
style states the background its colors were designed against. Defaults to
monokai on the dark chrome and to Pygments' own default on the light
one.
- --help /
-h
- Show this message and exit.
- --config
LOCATION
- Location of the configuration file. Supports local path with glob patterns
or remote URL.
- --no-config
- Ignore all configuration files and only use command line parameters and
environment variables.
- --validate-config
LOCATION
- Validate the configuration file and exit.
- --export-config
FORMAT
- Export the configuration in the selected format to <stdout>, then
exit.
[values: toml, yaml, json, json5, jsonc, hjson, xml, plist]
- --accessible
- Accessibility mode: disable colors and render tables in a borderless,
screen-reader-friendly format.
- --color[=auto|always|never]
- Colorize the output. A bare --color is the same as --color=always.
- --no-color
- Disable colorization (alias of --color=never).
- --progress /
--no-progress
- Show progress indicators during long operations. Disabled for
non-interactive output (pipes, dumb terminals, CI) and by
--accessible.
- --theme
[auto|dark|dracula|light|manpage|monokai|nord|solarized-dark]
- Color theme used for help screens.
- --table-format
FORMAT
- Rendering style of tables.
[values: aligned, asciidoc, colon-grid, csv, csv-excel, csv-excel-tab,
csv-unix, double-grid, double-outline, fancy-grid, fancy-outline, github,
grid, heavy-grid, heavy-outline, hjson, html, jira, json, json5, jsonc,
latex, latex-booktabs, latex-longtable, latex-raw, mediawiki, mixed-grid,
mixed-outline, moinmoin, orgtbl, outline, pipe, plain, presto, pretty,
psql, rounded-grid, rounded-outline, rst, simple, simple-grid,
simple-outline, textile, toml, tsv, unsafehtml, vertical, xml, yaml,
youtrack]
- --verbosity
LEVEL
- Either CRITICAL, ERROR, WARNING, INFO, DEBUG.
[values: CRITICAL, ERROR, WARNING, INFO, DEBUG]
- --verbose /
-v
- Increase the default WARNING verbosity by one level for each additional
repetition of the option.
- --quiet /
-q
- Decrease the default WARNING verbosity by one level for each additional
repetition of the option.
- --debug
- Shorthand for --verbosity DEBUG.
- SNIPPET_OUTPUT
- Path of the file to write. Its extension picks the format: .svg for an
image, .html for selectable text, .ansi for the escape sequences
themselves. Pass - to print those to the terminal, which draws no
window.
- SNIPPET_COLUMNS
- Width, in characters, the image is laid out at. Pass auto to take the
longest line the source holds, so nothing folds: a file was never wrapped
to a terminal's width, and code that soft-wrapped in the picture would
lose the indentation a reader is there to read.
- SNIPPET_BACKGROUND
- Terminal chrome the capture is drawn on, and the palette its colors
resolve against. Match it to the theme the captured CLI renders with: a
light-background theme washes out on the dark default.
- SNIPPET_PRESET
- Terminal to draw the capture as: its window decorations, palette, font and
prompt sigil. Anything stated alongside wins over it. Left out, the
capture keeps the renderer's own neutral window.
- SNIPPET_BORDER
- Color of the frame drawn around the terminal window, as CSS names it. Pass
none to draw no frame. Defaults to the one the chrome can show.
- SNIPPET_BORDER_WIDTH
- Thickness of that frame, in pixels.
- SNIPPET_RADIUS
- How round the window's corners are, in pixels. Zero squares them. Defaults
to 8, or to the rounding --preset terminal draws.
- SNIPPET_BACKDROP
- Color filling the image behind the window, margin included, as CSS names
it. Left transparent by default, so the page shows through.
- SNIPPET_SHADOW
- Color of the drop shadow lifting the window off the page, as CSS names it.
Pass none to draw no shadow. Defaults to the one the chrome calls
for.
- SNIPPET_MARGIN
- Transparent pixels left around the window, on all four sides. The room the
drop shadow falls into, so a capture drawing one wants some.
- SNIPPET_PADDING
- Pixels added inside the window, around the drawn text, on top of the few
the renderer adds on its own.
- SNIPPET_OPACITY
- How solid the window's body is. Under 1 it turns see-through, the way a
terminal set to transparency does: whatever the capture sits on shows
through it, while its text, frame and title bar keep their own paint.
- SNIPPET_WATERMARK
- Credit line drawn in the image's bottom-right corner, in the margin around
the window. Pass an empty string to draw none, or your own text to credit
your project instead.
- SNIPPET_WATERMARK_COLOR
- Color that credit line is drawn in, as CSS names it, alpha included.
Defaults to a neutral gray: the line sits in the transparent margin, so it
answers to the page embedding the image rather than to the chrome.
- SNIPPET_HEAD
- Keep only the first N lines.
- SNIPPET_TAIL
- Keep only the last N lines.
- SNIPPET_TRUNCATION
- Line standing in for what --head or --tail cut away.
- SNIPPET_LINE_NUMBERS
- Number the drawn lines in a gutter, the way Pygments does inline. Line 1
is the first line the picture shows.
- SNIPPET_EMPHASIZE
- Draw a band behind the lines named, as 2,4-5. Counted from 1 as the
picture draws them. Ranges are closed: state both ends.
- SNIPPET_TITLE
- Caption drawn in an SVG's window chrome, or an HTML document's title.
- SNIPPET_FRAGMENT
- For HTML, emit the bare block instead of a standalone document, to paste
into a page that has its own.
- SNIPPET_LANGUAGE
- Language the source is highlighted as, as Pygments names it. Guessed from
the file name, then from the content, when left out. See
https://pygments.org/languages/ for the ones it knows.
- SNIPPET_SYNTAX_STYLE
- Pygments style the source is colored with, which also paints the window: a
style states the background its colors were designed against. Defaults to
monokai on the dark chrome and to Pygments' own default on the light
one.
- SNIPPET__CLICK_DEFAULT_HELP
- Show this message and exit.
- SNIPPET_CONFIG
- Location of the configuration file. Supports local path with glob patterns
or remote URL.
- SNIPPET_VALIDATE_CONFIG
- Validate the configuration file and exit.
- SNIPPET_EXPORT_CONFIG
- Export the configuration in the selected format to <stdout>, then
exit.
- SNIPPET_ACCESSIBLE
- Accessibility mode: disable colors and render tables in a borderless,
screen-reader-friendly format.
- SNIPPET_COLOR
- Colorize the output. A bare --color is the same as --color=always.
- SNIPPET_NO_COLOR
- Disable colorization (alias of --color=never).
- SNIPPET_PROGRESS
- Show progress indicators during long operations. Disabled for
non-interactive output (pipes, dumb terminals, CI) and by
--accessible.
- SNIPPET_THEME
- Color theme used for help screens.
- SNIPPET_TABLE_FORMAT
- Rendering style of tables.
- SNIPPET_VERBOSITY
- Either CRITICAL, ERROR, WARNING, INFO, DEBUG.
- SNIPPET_VERBOSE
- Increase the default WARNING verbosity by one level for each additional
repetition of the option.
- SNIPPET_QUIET
- Decrease the default WARNING verbosity by one level for each additional
repetition of the option.
- SNIPPET_DEBUG
- Shorthand for --verbosity DEBUG.
- SNIPPET_TIME
- Measure and print elapsed execution time.
- SNIPPET_PARAMS
- Show all CLI parameters, their provenance, defaults and value, then
exit.
- SNIPPET_TREE
- Show the tree of nested subcommands and exit.
- SNIPPET_MAN
- Read the command's manual page and exit.
- SNIPPET_HELP_FORMAT
- Render the command in the given format and exit.
- SNIPPET_VERSION
- Show the version and exit.
~/.config/click-extra/{*.toml,*.yaml,*.yml,*.json,*.json5,*.jwcc,*.jsonc,*.hjson,*.ini,*.xml,*.plist,*.sqlite,*.sqlite3,*.conf,pyproject.toml}
- 0
- Success.
- 1
- A runtime error, or an aborted prompt (Ctrl-C, a declined
confirmation).
- 2
- A usage error: unknown option, invalid value, missing operand, or an
unparsable configuration file.