Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
27 changes: 27 additions & 0 deletions source/interpr.d
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,33 @@ int main (string [] args)
pos += 1;
steps = args[pos].to !(int);
}
else if (args[pos] == "-i")
{
pos += 1;
try
{
auto input = File(args[pos], "r");
stdin = input;
}
catch (Exception e)
{
stderr.writefln("Cannot find input file \"%s\", using stdin", args[pos]);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Почему желаемое поведение при ошибке -- читать из какого-то другого места?

Если я как пользователь ввожу неправильные аргументы -- я ожидаю, что мне скажут, что они неправильные, а не спокойно продолжат работать с чем-то, чего я не просил.

}

}
else if (args[pos] == "-o")
{
pos += 1;
try
{
auto output = File(args[pos], "w");
stdout = output;
}
catch (Exception e)
{
stderr.writefln("Cannot find output file \"%s\", using stdout", args[pos]);
}
}
else
{
fileName = args[pos];
Expand Down