Styling issues and new class name for the CLI

This commit is contained in:
Lefteris Karapetsas 2014-12-09 17:39:34 +01:00
parent 5ab37de94a
commit df82e26d5a
3 changed files with 98 additions and 111 deletions

View File

@ -17,9 +17,9 @@
/**
* @author Lefteris <lefteris@ethdev.com>
* @date 2014
* Solidity compiler context class.
* Solidity command line interface.
*/
#include "SolContext.h"
#include "CommandLineInterface.h"
#include <string>
#include <iostream>
@ -77,7 +77,6 @@ static inline bool outputToStdout(OutputType type)
return type == OutputType::STDOUT || type == OutputType::BOTH;
}
static std::istream& operator>>(std::istream& _in, OutputType& io_output)
{
std::string token;
@ -93,7 +92,7 @@ static std::istream& operator>>(std::istream& _in, OutputType& io_output)
return _in;
}
void SolContext::handleBytecode(string const& _argName,
void CommandLineInterface::handleBytecode(string const& _argName,
string const& _title,
string const& _contract,
string const& _suffix)
@ -126,7 +125,7 @@ void SolContext::handleBytecode(string const& _argName,
}
}
void SolContext::handleJson(DocumentationType _type,
void CommandLineInterface::handleJson(DocumentationType _type,
string const& _contract)
{
std::string argName;
@ -172,16 +171,7 @@ void SolContext::handleJson(DocumentationType _type,
}
}
bool SolContext::parseArguments(int argc, char** argv)
bool CommandLineInterface::parseArguments(int argc, char** argv)
{
#define OUTPUT_TYPE_STR "Legal values:\n" \
"\tstdout: Print it to standard output\n" \
@ -241,7 +231,7 @@ bool SolContext::parseArguments(int argc, char** argv)
return true;
}
bool SolContext::processInput()
bool CommandLineInterface::processInput()
{
if (!m_args.count("input-file"))
{
@ -302,7 +292,7 @@ bool SolContext::processInput()
return true;
}
void SolContext::actOnInput()
void CommandLineInterface::actOnInput()
{
// do we need AST output?
if (m_args.count("ast"))

View File

@ -17,7 +17,7 @@
/**
* @author Lefteris <lefteris@ethdev.com>
* @date 2014
* Solidity compiler context class.
* Solidity command line interface.
*/
#pragma once
@ -40,10 +40,10 @@ enum class OutputType: uint8_t
BOTH
};
class SolContext
class CommandLineInterface
{
public:
SolContext() {}
CommandLineInterface() {}
/// Parse command line arguments and return false if we should not continue
bool parseArguments(int argc, char** argv);

View File

@ -20,19 +20,16 @@
* Solidity commandline compiler.
*/
#include "SolContext.h"
#include "CommandLineInterface.h"
int main(int argc, char** argv)
{
dev::solidity::SolContext ctx;
if (!ctx.parseArguments(argc, argv))
dev::solidity::CommandLineInterface cli;
if (!cli.parseArguments(argc, argv))
return 1;
if (!ctx.processInput())
if (!cli.processInput())
return 1;
ctx.actOnInput();
cli.actOnInput();
return 0;
}