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

Closed
wants to merge 36 commits into from

Conversation

Maricaya
Copy link
Contributor

@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
Contributor Author

Maricaya commented Dec 21, 2024

closes #2214

@Maricaya
Copy link
Contributor 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
Contributor Author

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

@alixander
Copy link
Collaborator

@Maricaya this looks good to me, thanks for addressing the comments.

I'm not sure what happened but only one of your commits is signed, would you mind fixing that? Ready to merge after

Screenshot 2025-01-11 at 2 40 57 PM

@alixander
Copy link
Collaborator

#2291

@alixander alixander closed this Jan 17, 2025
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.

3 participants