wilzbach / tools-test

1 stars 0 forks source link

Implement -stdin for rdmd #176

Open wilzbach opened 6 years ago

wilzbach commented 6 years ago

Note: the issue was created automatically migrated from https://issues.dlang.org

Original bug ID: BZ#17985 From: Andre <andre@s-e-a-p.de> Reported version: D2 CC: @wilzbach, hsteoh@quickfur.ath.cx

wilzbach commented 6 years ago

Comment author: Andre <andre@s-e-a-p.de>

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 -

wilzbach commented 6 years ago

Comment author: hsteoh@quickfur.ath.cx

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).

wilzbach commented 6 years ago

Comment author: @wilzbach

With 2.078.0 DMD will support cat foo.d | dmd -run - which is probably what the creator was looking for?

wilzbach commented 6 years ago

Comment author: hsteoh@quickfur.ath.cx

No, this issue is asking for rdmd to support reading from stdin, not dmd.

wilzbach commented 6 years ago

Comment author: Andre <andre@s-e-a-p.de>

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:

wilzbach commented 6 years ago

Comment author: hsteoh@quickfur.ath.cx

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.

wilzbach commented 6 years ago

Comment author: @wilzbach

Fair enough. BTW rdmd doesn't add imports by defaults - only rdmd --eval <string> does.