CommandLineInterface: Accept the standard input stream as a parameter

This commit is contained in:
Kamil Śliwak 2021-06-16 21:12:27 +02:00
parent bb64d366ea
commit 4c479b5689
3 changed files with 7 additions and 3 deletions

View File

@ -99,6 +99,7 @@ ostream& CommandLineInterface::serr(bool _markAsUsed)
return m_serr;
}
#define cin
#define cout
#define cerr
@ -415,7 +416,7 @@ bool CommandLineInterface::readInputFilesAndConfigureFileReader()
}
if (m_options.input.addStdin)
m_fileReader.setSource(g_stdinFileName, readUntilEnd(cin));
m_fileReader.setSource(g_stdinFileName, readUntilEnd(m_sin));
if (m_fileReader.sourceCodes().size() == 0)
{
@ -513,7 +514,7 @@ bool CommandLineInterface::processInput()
{
string input;
if (m_options.input.standardJsonFile.empty())
input = readUntilEnd(cin);
input = readUntilEnd(m_sin);
else
{
try

View File

@ -40,10 +40,12 @@ class CommandLineInterface
{
public:
explicit CommandLineInterface(
std::istream& _sin,
std::ostream& _sout,
std::ostream& _serr,
CommandLineOptions const& _options = CommandLineOptions{}
):
m_sin(_sin),
m_sout(_sout),
m_serr(_serr),
m_options(_options)
@ -121,6 +123,7 @@ private:
/// stream has ever been used unless @arg _markAsUsed is set to false.
std::ostream& serr(bool _markAsUsed = true);
std::istream& m_sin;
std::ostream& m_sout;
std::ostream& m_serr;
bool m_hasOutput = false;

View File

@ -54,7 +54,7 @@ static void setDefaultOrCLocale()
int main(int argc, char** argv)
{
setDefaultOrCLocale();
solidity::frontend::CommandLineInterface cli(cout, cerr);
solidity::frontend::CommandLineInterface cli(cin, cout, cerr);
if (!cli.parseArguments(argc, argv))
return 1;
if (!cli.processInput())