add support of dark-theme attribute

This commit is contained in:
Dmitriy Pleshevskiy 2023-02-25 22:11:14 +03:00
parent 1e05739a5e
commit f83a5503c9
Signed by: pleshevskiy
GPG Key ID: 79C4487B44403985
3 changed files with 15 additions and 13 deletions

View File

@ -1,8 +1,8 @@
# *W*rapped _d2_ # *W*rapped _d2_
A wrapper over [d2] which allows to use `layout`, `theme`, `pad`, `sketch` and A wrapper over [d2] which allows to use `layout`, `theme`, `dark-theme`, `pad`,
`port` attributes from d2 file. All arguments will be passed to the d2 cli, but `sketch` and `port` attributes from d2 file. All arguments will be passed to the
these additional configs overwrite cli arguments with the same name. d2 cli, but these additional configs overwrite cli arguments with the same name.
[d2]: https://github.com/terrastruct/d2 [d2]: https://github.com/terrastruct/d2

View File

@ -32,11 +32,11 @@
}, },
"nixpkgs": { "nixpkgs": {
"locked": { "locked": {
"lastModified": 1676518424, "lastModified": 1677262115,
"narHash": "sha256-OsJSBwl9Hayh/bmxDtUyxm2U6btaBHuLvviE9KpMmwQ=", "narHash": "sha256-DPkHiJw2QnKYAzQXBlwelwghxbcD5oigK2kLPHMpMQ8=",
"owner": "NixOS", "owner": "NixOS",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "a592a97fcedae7a06b8506623b25fd38a032ad13", "rev": "806075be2bdde71895359ed18cb530c4d323e6f6",
"type": "github" "type": "github"
}, },
"original": { "original": {
@ -71,11 +71,11 @@
"nixpkgs": "nixpkgs_2" "nixpkgs": "nixpkgs_2"
}, },
"locked": { "locked": {
"lastModified": 1676488781, "lastModified": 1677351205,
"narHash": "sha256-lP2UWGwangM1OSBOx0EFXOtnSBuyTJn3yza3Ujb9/C8=", "narHash": "sha256-QfzWWLbpX7iYXSDWbqshF7VAXVnz/SAMu5JjEXPlbfA=",
"ref": "refs/heads/main", "ref": "refs/heads/main",
"rev": "5f07d4e256c1d8caefd52563737b1e3c023b5d35", "rev": "1230292d1e04a1fb9228ae48d202c42b74eab5d2",
"revCount": 21, "revCount": 22,
"type": "git", "type": "git",
"url": "https://git.pleshevski.ru/mynix/tools" "url": "https://git.pleshevski.ru/mynix/tools"
}, },

8
wd2
View File

@ -10,9 +10,9 @@ function print_help() {
Usage: Usage:
wd2 [FLAGS...] file.d2 [file.svg | file.png] wd2 [FLAGS...] file.d2 [file.svg | file.png]
A wrapper over d2 which allows to use \`layout\`, \`theme\`, \`pad\`, A wrapper over d2 which allows to use 'layout', 'theme', 'dark-theme',
\`sketch\` and \`port\` attributes from d2 file. All arguments will 'pad', 'sketch' and 'port' attributes from d2 file. All arguments will
be passed to the d2 cli, but these additional configs overwrite cli be passed to the d2 cli, but these additional configs overwrite cli
arguments with the same name. arguments with the same name.
$(d2 --help | tail -n +6 - | sed -e 's/d2 \(layout\|fmt\)/wd2 \1/') $(d2 --help | tail -n +6 - | sed -e 's/d2 \(layout\|fmt\)/wd2 \1/')
@ -61,6 +61,7 @@ fi
set +e set +e
d2_layout=$(get_attr_value "layout") d2_layout=$(get_attr_value "layout")
d2_theme=$(get_attr_value "theme") d2_theme=$(get_attr_value "theme")
d2_dark_theme=$(get_attr_value "dark-theme")
d2_pad=$(get_attr_value "pad") d2_pad=$(get_attr_value "pad")
d2_sketch=$(get_attr_value "sketch") d2_sketch=$(get_attr_value "sketch")
d2_port=$(get_attr_value "port") d2_port=$(get_attr_value "port")
@ -69,6 +70,7 @@ set -e
d2 "${d2_args[@]}" \ d2 "${d2_args[@]}" \
${d2_layout:+--layout=${d2_layout}} \ ${d2_layout:+--layout=${d2_layout}} \
${d2_theme:+--theme=${d2_theme}} \ ${d2_theme:+--theme=${d2_theme}} \
${d2_dark_theme:+--dark-theme=${d2_dark_theme}} \
${d2_pad:+--pad=${d2_pad}} \ ${d2_pad:+--pad=${d2_pad}} \
${d2_sketch:+--sketch=${d2_sketch}} \ ${d2_sketch:+--sketch=${d2_sketch}} \
${d2_port:+--port=${d2_port}} ${d2_port:+--port=${d2_port}}