-
Notifications
You must be signed in to change notification settings - Fork 57
sdfmt: Support stdin input and --assume-filename
option
#363
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
base: master
Are you sure you want to change the base?
Conversation
Hey, thanks for the PR. Thanks to github, I did not see that earlier, as github provide no useful dashboard of what one has to review. Anyways, a couple of remarks.
|
this functionality helps with editor support. The editor can send stuff through stdin (an edited but not saved file, for example), while letting sdfmt do config lookup as-if it is processing the file specified by |
src/driver/sdfmt.d
Outdated
const sanitizedData = convertToUTF8(stdinData); | ||
|
||
const fakeFilename = | ||
assumeFilename.length ? assumeFilename : "stdin"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't "stdin" be changed to something like "." such that config file lookup starts from cwd ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed that's exactly what it'd do, treating it like a local stdin.d
file in cwd (but having a nicer stdin
'name' in potential error msges etc.). But totally untested. ;)
Yeah, we at Symmetry need it for exactly the same reason, for our own little VS Code extension formatting the SIL .d files (just giving Amaury the context). [It currently needs to dump stdin to a temp file in the original source dir, which updates the directory modification timestamp, which is detrimental for our reggae/ninja build based on timestamps).
Not AFAICT, I was looking for some
Fine by me, no preference from my side (DMD/LDC use
Would you have any handy pointers? |
Okay, I've changed it to read from stdin if no files are provided in the command line, and fixed the config file lookup (fake path set too late...). Wrt. tests, I've had a quick glance and decided to do a 2nd pass for the current sdfmt tests - passing all of these files via stdin in the 2nd pass, and using the |
I've been reading this multiple times, and I'm still not sure how to be directive about it, but it seems clear to me that there is a problem in approach. We are adding special cases all over the place, and the special case path often has more code than the happy case. |
'All over the place' = the 2 tiny As you haven't given me any pointers for your custom test framework, I came up with something. Please do feel free to rework that. |
4acd1ab
to
e854d3d
Compare
0896895
to
5a79292
Compare
7ce40a5
to
4dbe602
Compare
Implementing #262.
The only thing I've tested is this:
echo "module abc;" | bin/sdfmt -
, which did output the expectedmodule abc;
(extra space removed) to stdout. ;)