mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
Read from files and stdin.
This commit is contained in:
parent
ec3298535e
commit
c54f31d308
@ -310,21 +310,18 @@ void CommandLineInterface::handleFormal()
|
|||||||
|
|
||||||
void CommandLineInterface::readInputFilesAndConfigureRemappings()
|
void CommandLineInterface::readInputFilesAndConfigureRemappings()
|
||||||
{
|
{
|
||||||
|
vector<string> inputFiles;
|
||||||
|
bool addStdin = false;
|
||||||
if (!m_args.count("input-file"))
|
if (!m_args.count("input-file"))
|
||||||
{
|
addStdin = true;
|
||||||
string s;
|
|
||||||
while (!cin.eof())
|
|
||||||
{
|
|
||||||
getline(cin, s);
|
|
||||||
m_sourceCodes[g_stdinFileName].append(s + '\n');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
else
|
||||||
for (string path: m_args["input-file"].as<vector<string>>())
|
for (string path: m_args["input-file"].as<vector<string>>())
|
||||||
{
|
{
|
||||||
auto eq = find(path.begin(), path.end(), '=');
|
auto eq = find(path.begin(), path.end(), '=');
|
||||||
if (eq != path.end())
|
if (eq != path.end())
|
||||||
path = string(eq + 1, path.end());
|
path = string(eq + 1, path.end());
|
||||||
|
else if (path == "-")
|
||||||
|
addStdin = true;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
auto infile = boost::filesystem::path(path);
|
auto infile = boost::filesystem::path(path);
|
||||||
@ -345,6 +342,15 @@ void CommandLineInterface::readInputFilesAndConfigureRemappings()
|
|||||||
}
|
}
|
||||||
m_allowedDirectories.push_back(boost::filesystem::path(path).remove_filename());
|
m_allowedDirectories.push_back(boost::filesystem::path(path).remove_filename());
|
||||||
}
|
}
|
||||||
|
if (addStdin)
|
||||||
|
{
|
||||||
|
string s;
|
||||||
|
while (!cin.eof())
|
||||||
|
{
|
||||||
|
getline(cin, s);
|
||||||
|
m_sourceCodes[g_stdinFileName].append(s + '\n');
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CommandLineInterface::parseLibraryOption(string const& _input)
|
bool CommandLineInterface::parseLibraryOption(string const& _input)
|
||||||
@ -399,9 +405,9 @@ bool CommandLineInterface::parseArguments(int _argc, char** _argv)
|
|||||||
po::options_description desc(
|
po::options_description desc(
|
||||||
R"(solc, the Solidity commandline compiler.
|
R"(solc, the Solidity commandline compiler.
|
||||||
Usage: solc [options] [input_file...]
|
Usage: solc [options] [input_file...]
|
||||||
Compiles the given Solidity input files (or the standard input if none given) and
|
Compiles the given Solidity input files (or the standard input if none given or
|
||||||
outputs the components specified in the options at standard output or in files in
|
"-" is used as a file name) and outputs the components specified in the options
|
||||||
the output directory, if specified.
|
at standard output or in files in the output directory, if specified.
|
||||||
Example: solc --bin -o /tmp/solcoutput contract.sol
|
Example: solc --bin -o /tmp/solcoutput contract.sol
|
||||||
|
|
||||||
Allowed options)",
|
Allowed options)",
|
||||||
|
Loading…
Reference in New Issue
Block a user