Skip to content

Conversation

@silwol
Copy link
Contributor

@silwol silwol commented Nov 2, 2025

Not quite sure whether the tinytemplate templates are formatted as expected, I tried to keep the output format identical when the parameter is absent, and just add a single line if it is present. That results in a somewhat strange template format, not sure what your preference is here.

Hope the PR suits in general, please let me know whether the general direction is ok or if you see room for improvement somewhere.

@kurotych kurotych self-requested a review November 2, 2025 13:24
Copy link
Owner

@kurotych kurotych left a comment

Choose a reason for hiding this comment

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

Hello @silwol, I'm very grateful for your contribution.
Everything looks good overall. Please check the two comments, and we’ll be good to go.

src/cli.rs Outdated
Comment on lines 64 to 67
"top-to-bottom",
"bottom-to-top",
"left-to-right",
"right-to-left",
Copy link
Owner

@kurotych kurotych Nov 2, 2025

Choose a reason for hiding this comment

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

Let's have short values: tb, bt, lr, rl in cli parameters

use tinytemplate::{format_unescaped, TinyTemplate};

static MERMAID_TEMPLATE: &str = r#"erDiagram
static MERMAID_TEMPLATE: &str = r#"erDiagram{{ if direction }}
Copy link
Owner

@kurotych kurotych Nov 2, 2025

Choose a reason for hiding this comment

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

start if direction from new line, otherwise it produces white-spaces

static MERMAID_TEMPLATE: &str = r#"erDiagram
{{ if direction }}direction {direction}{{ endif }}
{{ for ent in entities}}{ent}{{ endfor }}
{{ for en in enums}}{en}{{ endfor }}
{{ for fk in foreign_keys}}{fk}{{ endfor }}
"#;

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The whitespace was intentional, I thought an indentation is required for mermaid diagrams, maybe I'm wrong.

If I understand correctly, your proposal will create an empty line if no direction is passed in. That's what I tried to avoid with my approach. If this empty line and the "missing" indentation don't matter, we can go ahead with the proposal, which is what I pushed now.

Copy link
Owner

@kurotych kurotych Nov 3, 2025

Choose a reason for hiding this comment

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

indentation is required for mermaid diagrams,

indentation is not required

your proposal will create an empty line if no direction is passed in. That's what I tried to avoid with my approach.

You are right. It looks better. I will return if statement to the top to avoid empty line in missing parameter case.

@kurotych kurotych merged commit e9b11ad into kurotych:main Nov 3, 2025
1 of 2 checks passed
@silwol silwol deleted the add-direction branch November 3, 2025 07:01
@silwol
Copy link
Contributor Author

silwol commented Nov 3, 2025

Thanks a lot for merging! 🚀

@kurotych
Copy link
Owner

kurotych commented Nov 3, 2025

Thanks a lot for merging! 🚀

Thank you for your contribution 👍

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