add support of port attribute

This commit is contained in:
Dmitriy Pleshevskiy 2023-02-16 23:52:40 +03:00
parent f387572eb0
commit 243d3bfb4f
Signed by: pleshevskiy
GPG Key ID: 1B59187B161C0215
2 changed files with 10 additions and 8 deletions

View File

@ -1,8 +1,8 @@
# *W*rapped _d2_
A wrapper over [d2] which allows to use \`layout\`, \`theme\`, \`pad\`
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 `layout`, `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.
[d2]: https://github.com/terrastruct/d2

12
wd2
View File

@ -10,10 +10,10 @@ function print_help() {
Usage:
wd2 [FLAGS...] file.d2 [file.svg | file.png]
A wrapper over d2 which allows to use \`layout\`, \`theme\`, \`pad\`
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 \`layout\`, \`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.
$(d2 --help | tail -n +6 - | sed -e 's/d2 \(layout\|fmt\)/wd2 \1/')
EOF
@ -63,11 +63,13 @@ d2_layout=$(get_attr_value "layout")
d2_theme=$(get_attr_value "theme")
d2_pad=$(get_attr_value "pad")
d2_sketch=$(get_attr_value "sketch")
d2_port=$(get_attr_value "port")
set -e
d2 "${d2_args[@]}" \
${d2_layout:+--layout=${d2_layout}} \
${d2_theme:+--theme=${d2_theme}} \
${d2_pad:+--pad=${d2_pad}} \
${d2_sketch:+--sketch=${d2_sketch}}
${d2_sketch:+--sketch=${d2_sketch}} \
${d2_port:+--port=${d2_port}}