make CLI prompt configurable
This commit is contained in:
parent
135949ee19
commit
a3c284408e
2 changed files with 9 additions and 10 deletions
|
|
@ -53,16 +53,18 @@ namespace fc { namespace rpc {
|
|||
|
||||
virtual void getline( const fc::string& prompt, fc::string& line );
|
||||
|
||||
void set_prompt( const string& prompt ) { _prompt = prompt; }
|
||||
|
||||
private:
|
||||
void run()
|
||||
{
|
||||
while( !_run_complete.canceled() )
|
||||
{
|
||||
try {
|
||||
while( !_run_complete.canceled() )
|
||||
{
|
||||
try {
|
||||
std::string line;
|
||||
try
|
||||
{
|
||||
getline( ">>> ", line );
|
||||
getline( _prompt.c_str(), line );
|
||||
}
|
||||
catch ( const fc::eof_exception& e )
|
||||
{
|
||||
|
|
@ -88,8 +90,9 @@ namespace fc { namespace rpc {
|
|||
{
|
||||
std::cout << e.to_detail_string() << "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
std::string _prompt = ">>>";
|
||||
std::map<string,std::function<string(variant,const variants&)> > _result_formatters;
|
||||
fc::future<void> _run_complete;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,4 +1,3 @@
|
|||
|
||||
#include <fc/rpc/cli.hpp>
|
||||
#include <fc/thread/thread.hpp>
|
||||
|
||||
|
|
@ -31,10 +30,7 @@
|
|||
|
||||
namespace fc { namespace rpc {
|
||||
|
||||
void cli::getline(
|
||||
const fc::string& prompt,
|
||||
fc::string& line
|
||||
)
|
||||
void cli::getline( const fc::string& prompt, fc::string& line)
|
||||
{
|
||||
// getting file descriptor for C++ streams is near impossible
|
||||
// so we just assume it's the same as the C stream...
|
||||
|
|
|
|||
Loading…
Reference in a new issue