Bug 17985 – Implement -stdin for rdmd

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P1
Component
tools
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-11-16T18:50:15Z
Last change time
2019-06-14T20:36:37Z
Assigned to
No Owner
Creator
Andre

Comments

Comment #0 by andre — 2017-11-16T18:50:15Z
Similiar to the -stdin enhancement for dmd (https://github.com/dlang/dmd/pull/6880) it would make sense to implement it for rdmd too. This would enable following command: echo import std.stdio; void main() { writeln("Success"); } | rdmd -
Comment #1 by hsteoh — 2017-12-14T01:19:14Z
Doesn't rdmd already have --eval for this purpose? Of course, being able to read from stdin has its own value (e.g., run rdmd on output produced by some code generating program via stdin, without needing to create a temporary file).
Comment #2 by greeenify — 2017-12-24T22:31:17Z
With 2.078.0 DMD will support `cat foo.d | dmd -run -` which is probably what the creator was looking for?
Comment #3 by hsteoh — 2017-12-25T02:06:19Z
No, this issue is asking for rdmd to support reading from stdin, not dmd.
Comment #4 by andre — 2017-12-25T09:00:56Z
It's great dmd -run supports now -stdin. Thanks a lot. That is viable workaround. I would like to keep this issue open to get the same functionality for rdmd, because: - rdmd is the advertised tool to work with D in a script like way - dmd -run is a less knower argument. Most developers will try `cat foo.d | rdmd -`. Another benefit is, I always write the run argument wrong "--run". Be able to just write `...| rdmd -` is convenient
Comment #5 by hsteoh — 2017-12-28T18:43:53Z
One advantage `echo ... | rdmd -` has over `echo ... | dmd --run -` is that rdmd inserts a bunch of standard imports into the code, so that you don't have to keep typing `import std.stdio; ...` in every echo command. So yes, this is still a valid ER.
Comment #6 by greeenify — 2017-12-28T18:49:34Z
Fair enough. BTW rdmd doesn't add imports by defaults - only `rdmd --eval <string>` does.
Comment #7 by andre — 2019-06-14T20:36:37Z
As rdmd is deprecated, I will close this issue. In the meantime this feature was also added to dub.