mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
CommandLineInterface: Accept the standard input stream as a parameter
This commit is contained in:
parent
bb64d366ea
commit
4c479b5689
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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())
|
||||
|
Loading…
Reference in New Issue
Block a user