cargo_zng::res::built_in

Constant RP_HELP

source
const RP_HELP: &str = "
Replace ${VAR|<file|!cmd} occurrences in the content

The request file:
  source/greetings.txt.zr-rp
   | Thanks for using ${ZR_APP}!

Writes the text content with ZR_APP replaced:
  target/greetings.txt
  | Thanks for using Foo App!

The parameters syntax is ${VAR|!|<[:[case]][?else]}:

${VAR}          — Replaces with the env var value, or fails if it is not set.
${VAR:case}     — Replaces with the env var value, case converted.
${VAR:?else}    — If VAR is not set or is empty uses 'else' instead.

${<file.txt}    — Replaces with the 'file.txt' content. 
                  Paths are relative to the workspace root.
${<file:case}   — Replaces with the 'file.txt' content, case converted.
${<file:?else}  — If file cannot be read or is empty uses 'else' instead.

${!cmd -h}      — Replaces with the stdout of the bash script line. 
                  The script runs the same bash used by '.zr-sh'.
                  The script must be defined all in one line.
                  A separate bash instance is used for each occurrence.
                  The working directory is the workspace root.
${!cmd:case}    — Replaces with the stdout, case converted. 
                  If the script contains ':' quote it with double quotes\"
$!{!cmd:?else}  — If script fails or ha no stdout, uses 'else' instead.

$${VAR}         — Escapes $, replaces with '${VAR}'.

The :case functions are:

:k or :kebab  — kebab-case (cleaned)
:K or :KEBAB  — UPPER-KEBAB-CASE (cleaned)
:s or :snake  — snake_case (cleaned)
:S or :SNAKE  — UPPER_SNAKE_CASE (cleaned)
:l or :lower  — lower case
:U or :UPPER  — UPPER CASE
:T or :Title  — Title Case
:c or :camel  — camelCase (cleaned)
:P or :Pascal — PascalCase (cleaned)
:Tr or :Train — Train-Case (cleaned)
:           — Unchanged
:clean      — Cleaned
:f or :file — Sanitize file name

Cleaned values only keep ascii alphabetic first char and ascii alphanumerics, ' ', '-' and '_' other chars.
More then one case function can be used, separated by pipe ':T|f' converts to title case and sanitize for file name. 


The fallback(:?else) can have nested ${...} patterns. 
You can set both case and else: '${VAR:case?else}'.

Variables:

All env variables can be used, of particular use with this tool are:

ZR_APP — package.metadata.zng.about.app or package.name
ZR_ORG — package.metadata.zng.about.org or the first package.authors
ZR_VERSION — package.version
ZR_DESCRIPTION — package.description
ZR_HOMEPAGE — package.homepage
ZR_LICENSE — package.license
ZR_PKG_NAME — package.name
ZR_PKG_AUTHORS — package.authors
ZR_CRATE_NAME — package.name in snake_case
ZR_QUALIFIER — package.metadata.zng.about.qualifier

See `zng::env::about` for more details about metadata vars.
See the cargo-zng crate docs for a full list of ZR vars.

";