Kapow is a template processor that provides the following directives to support injecting file contents, command output, current date/time, elapsed time, etc in generated output.
It can be used in some different ways:
kapow path/to/file.ext
; optionally save the output via redirection:
kapow path/to/file.ext >output.ext
#!/usr/bin/env kapow
as the first line of a (Markdown) file,
make it "executable" via chmod +x file.ext
, then run via ./file.ext
(see
note #3 under [block directives]).Kapow is designed around Markdown syntax, but can be used with any text format that works with its directives.
Directive | Description
---|---
!inc:path
| Include file contents; path is relative to its containing file
!run:command
| Run command and insert stdout
Notes:
./file.ext
.Directive | Example | Description
---|---|---
`!elapsed`
| 0s | Processing time
`!now`
| 2023-05-03T12:45:48Z | Current date/time in UTC / RFC 3339
`!now:local`
| Wed 03 May 2023 08:45:48 EDT | Current date/time in local timezone
`!now:local:%A %H:%M`
| Wednesday 08:45 | Current date/time in local timezone and custom format
`!now:MST7MDT`
| Wed 03 May 2023 06:45:48 MDT | Current date/time in custom timezone
`!now:MST7MDT:%A %H:%M`
| Wednesday 06:45 | Current date/time in custom timezone and format
`!now:US/Hawaii`
| Wed 03 May 2023 02:45:48 HST | Current date/time in custom locale
`!now:US/Hawaii:%A %H:%M`
| Wednesday 02:45 | Current date/time in custom locale and format
`!now:UTC:%A %H:%M`
| Wednesday 12:45 | Current date/time in UTC and custom format
`!now:x`
| Xh42Cjm | Current date/time in "x" format
`!today`
| 2023-05-03 | Current date in UTC / RFC 3339
`!today:local`
| 2023-05-03 | Current date in local timezone
`!today:MST7MDT`
| 2023-05-03 | Current date in custom timezone
`!today:MST7MDT:%v`
| 3-May-2023 | Current date in custom timezone and format
`!today:US/Hawaii`
| 2023-05-03 | Current date in custom locale
`!today:US/Hawaii:%x`
| 05/03/23 | Current date in custom locale and format
`!today:UTC:%A`
| Wednesday | Current date in UTC and custom format
!
with a backslash: \!
.bash
cargo install kapow bat
NOTE: If [bat
] is installed, Kapow uses it for syntax highlighting and paging
(see the -p
, -P
, -H
, -l
options).
text
$ kapow -V
kapow 2.6.0
```text $ kapow -h KAPOW!
Usage: kapow [OPTIONS] [INPUT_FILES]...
Arguments: [INPUT_FILES]... Input file(s) [default: -]
Options:
-p Page output
-P Do not page output
-H Disable syntax highlighting
-l
-r
option uses [bat
] for paging and syntax highlighting if you have it
installed (optional).Code | Description ---|--- 101 | Could not read input file 102 | Could not read included file 103 | Could not change directory
See the readme
task in Makefile.toml
:
t/VERSION.md
from t/VERSION.t.md
!run:../target/release/kapow -V
t/USAGE.md
from t/USAGE.t.md
!run:../target/release/kapow -h
README.md
from t/README.md
!inc:VERSION.md
!inc:USAGE.md
`!now`
(all variants)bash
cargo install cargo-edit cargo-make cargo-outdated dtg kapow \
miniserve