add support of force_appendix
This commit is contained in:
parent
2b2aa5f8e6
commit
720c006286
2 changed files with 36 additions and 10 deletions
16
README.md
16
README.md
|
@ -1,8 +1,8 @@
|
|||
# *W*rapped _d2_
|
||||
|
||||
A wrapper over [d2] which allows to use `layout`, `theme`, `dark-theme`, `pad`,
|
||||
`sketch` and `port` attributes from d2 file. All arguments will be passed to the
|
||||
d2 cli, but these additional configs overwrite cli arguments with the same name.
|
||||
A wrapper over [d2] which allows to use cli/env configuratios as additional
|
||||
specific attributes from d2 file. All these attributes will be passed to the d2
|
||||
cli and overwrite cli parameters with the same name.
|
||||
|
||||
[d2]: https://github.com/terrastruct/d2
|
||||
|
||||
|
@ -48,6 +48,16 @@ You can also use inline style to configure d2
|
|||
x -> y -> z
|
||||
```
|
||||
|
||||
# Supported configurations
|
||||
|
||||
- port
|
||||
- layout
|
||||
- theme
|
||||
- dark-theme
|
||||
- pad
|
||||
- sketch
|
||||
- force-appendix
|
||||
|
||||
# Limitation
|
||||
|
||||
You have to restart the watch server when you change the `layout`, `theme`,
|
||||
|
|
30
wd2
30
wd2
|
@ -8,12 +8,23 @@ d2_input_file=
|
|||
function print_help() {
|
||||
cat <<EOF
|
||||
Usage:
|
||||
wd2 [FLAGS...] file.d2 [file.svg | file.png]
|
||||
wd2 [--watch] [FLAGS...] file.d2 [file.svg | file.png]
|
||||
|
||||
A wrapper over d2 which allows to use 'layout', 'theme', 'dark-theme',
|
||||
'pad', 'sketch' and 'port' attributes from d2 file. All arguments will
|
||||
be passed to the d2 cli, but these additional configs overwrite cli
|
||||
arguments with the same name.
|
||||
A wrapper over d2 which allows to use cli/env configuratios as additional
|
||||
specific attributes from d2 file. All these attributes will be passed to the d2
|
||||
cli and overwrite cli parameters with the same name.
|
||||
|
||||
# Supported configurations
|
||||
|
||||
- port
|
||||
- layout
|
||||
- theme
|
||||
- dark-theme
|
||||
- pad
|
||||
- sketch
|
||||
- force-appendix
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
$(d2 --help | tail -n +6 - | sed -e 's/d2 \(layout\|fmt\)/wd2 \1/')
|
||||
EOF
|
||||
|
@ -48,7 +59,10 @@ function parse_args() {
|
|||
}
|
||||
|
||||
function get_attr_value() {
|
||||
head -n10 "$d2_input_file" | grep "$1" | awk -F"$1: " '{ print $2 }' | cut -d';' -f1
|
||||
grep "^#" "$d2_input_file" \
|
||||
| grep "$1" \
|
||||
| awk -F"$1: " '{ print $2 }' \
|
||||
| cut -d';' -f1
|
||||
}
|
||||
|
||||
parse_args "$@"
|
||||
|
@ -65,6 +79,7 @@ d2_dark_theme=$(get_attr_value "dark-theme")
|
|||
d2_pad=$(get_attr_value "pad")
|
||||
d2_sketch=$(get_attr_value "sketch")
|
||||
d2_port=$(get_attr_value "port")
|
||||
d2_force_appendix=$(get_attr_value "force-appendix")
|
||||
set -e
|
||||
|
||||
d2 "${d2_args[@]}" \
|
||||
|
@ -73,5 +88,6 @@ d2 "${d2_args[@]}" \
|
|||
${d2_dark_theme:+--dark-theme=${d2_dark_theme}} \
|
||||
${d2_pad:+--pad=${d2_pad}} \
|
||||
${d2_sketch:+--sketch=${d2_sketch}} \
|
||||
${d2_port:+--port=${d2_port}}
|
||||
${d2_port:+--port=${d2_port}} \
|
||||
${d2_force_appendix:+--force-appendix=${d2_force_appendix}}
|
||||
|
||||
|
|
Loading…
Reference in a new issue