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 validate command hates long lines #2491

Open
kubukoz opened this issue Dec 19, 2024 · 3 comments
Open

CLI validate command hates long lines #2491

kubukoz opened this issue Dec 19, 2024 · 3 comments
Labels
needs-discussion This issue/PR requires more discussion with community.

Comments

@kubukoz
Copy link
Contributor

kubukoz commented Dec 19, 2024

When you run validate, build or any other command that validates your model, if the sourceLocation in the validation events points to a compact JSON file (say, one of the AWS specs), the CLI will output basically a bunch of blank lines which will look terrible in the terminal.

Even with a smaller JSON file, like:

{"smithy":"2.0","shapes":{"example.weather#Home":{"type":"operation","input":{"target":"smithy.api#Unit"},"output":{"target":"smithy.api#Unit"},"traits":{"smithy.api#http":{"method":"GET","uri":"/"}}},"example.weather#Weather":{"type":"service","operations":[{"target":"example.weather#Home"}]}}}

Running validate yields:

image

which doesn't seem very useful with the source location.

Note: it's entirely possible that I've already reported this, because I remember writing about it, but I can't find any issue for this.

@kubukoz
Copy link
Contributor Author

kubukoz commented Dec 19, 2024

Apparently, it affects long lines in IDL files too:

$version: "2"

namespace example.weather

enum A {
                                                                                        result = "res"
}

although I can't imagine this happening often for someone using a formatter.

image

@JordonPhillips
Copy link
Contributor

I'm not sure there's a great way to display this. We could wrap the line, but I don't think that would look great either. We could also truncate from the beginning, but that would be even more confusing I think. I'll check with the rest of the team to see what they think about the options when everybody is back from the holiday vacations.

At the very least though, the red arrow shouldn't go past the truncation marker.

@JordonPhillips JordonPhillips added the needs-discussion This issue/PR requires more discussion with community. label Dec 23, 2024
@kubukoz
Copy link
Contributor Author

kubukoz commented Dec 23, 2024

I'd look at how other languages do it. In Scala, for example, the beginning gets truncated but you also see the line/column numbers, allowing you to find the exact spot:

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs-discussion This issue/PR requires more discussion with community.
Projects
None yet
Development

No branches or pull requests

2 participants