Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cli: add format flag to support PNG output to stdout #2257

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

Maricaya
Copy link

@Maricaya Maricaya commented Dec 21, 2024

Add --format flag to enable PNG output to stdout, allowing users to pipe D2 diagram output in PNG format to other tools.

Changes:

  • Add format flag support for PNG output to stdout
  • Add test cases for format flag handling
  • Update getOutputFormat to handle format flags properly

Example usage:

d2 input.d2 --stdout-format png -

Test: ./make.sh test

image

@Maricaya
Copy link
Author

Maricaya commented Dec 21, 2024

closes #2214

@Maricaya
Copy link
Author

Hi @alixander this is my first PR for D2, please let me know if I’ve missed anything!

Copy link
Collaborator

@alixander alixander left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for your first contribution! Looks mostly good, just some minor comments

You'll need to update the man page too please: https://github.com/terrastruct/d2/blob/master/ci/release/template/man/d2.1

and add a line to next.md as a new feature: https://github.com/terrastruct/d2/blob/master/ci/release/changelogs/next.md

d2cli/export.go Outdated Show resolved Hide resolved
d2cli/export.go Outdated Show resolved Hide resolved
d2cli/export.go Outdated Show resolved Hide resolved
d2cli/main.go Outdated Show resolved Hide resolved
d2cli/export.go Outdated Show resolved Hide resolved
d2cli/main.go Show resolved Hide resolved
@Maricaya
Copy link
Author

Hi @alixander, Thank you for your detailed review and guidance! I've completed the requested updates. 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants