Skip to content

Commit ffd2d57

Browse files
committed
Support reading from Unix pipes and file redirects
1 parent da2be38 commit ffd2d57

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

source/app.d

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
module calcool.app;
2+
23
version (CLI_APP) {
34
import std.stdio;
45
import std.getopt;

source/calcool/lexer.d

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
module calcool.lexer;
22
import std.stdio;
33
import std.ascii;
4-
54
import calcool.token;
65
import calcool.exceptions;
76

87
public class Lexer {
98
private:
109
File input;
10+
1111
uint pos = 0;
1212
string line;
1313
public:
@@ -21,8 +21,17 @@ public:
2121

2222
Token[] nextLine(in string stringInput = null) {
2323
if (stringInput is null) {
24-
if (input is stdin)
25-
write(">> ");
24+
if (input is stdin) {
25+
version (Posix) {
26+
import core.sys.posix.unistd : isatty;
27+
28+
if (isatty(stdin.fileno))
29+
write(">> ");
30+
} else {
31+
write(">> ");
32+
}
33+
}
34+
2635
line = input.readln();
2736
if (line is null) {
2837
return [];

0 commit comments

Comments
 (0)