Skip to content

Commit

Permalink
improved argstream help handling
Browse files Browse the repository at this point in the history
  • Loading branch information
csoler committed Feb 4, 2024
1 parent 682115f commit e597a03
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
3 changes: 1 addition & 2 deletions src/rsserver/rsinit.cc
Expand Up @@ -206,8 +206,7 @@ static const int SSLPWD_LEN = 64;

void RsInit::InitRsConfig()
{
RsInfo() << "libretroshare version: " << RS_HUMAN_READABLE_VERSION
<< std::endl;
//RsDbg() << "libretroshare version: " << RS_HUMAN_READABLE_VERSION;

rsInitConfig = new RsInitConfig;

Expand Down
14 changes: 10 additions & 4 deletions src/util/argstream.h
Expand Up @@ -252,7 +252,7 @@ namespace
inline bool helpRequested() const;
inline bool isOk() const;
inline std::string errorLog() const;
inline std::string usage(bool skipCommandLine = false) const;
inline std::string usage(bool skipCommandLine = false,bool indent=true) const;
inline bool defaultErrorHandling(bool ignoreUnused=false,bool skipCommandLine=false) const;
static inline char uniqueLetter();
protected:
Expand Down Expand Up @@ -341,7 +341,11 @@ namespace
}
else
{
os<<"(default="<<initialValue_<<")";
std::ostringstream ss;
ss << "(default="<<initialValue_<<")";

if(ss.str().size() > 10)
os<<ss.str();
}
return os.str();
}
Expand Down Expand Up @@ -569,7 +573,7 @@ namespace
return helpRequested_;
}
inline std::string
argstream::usage(bool skipCommandLine) const
argstream::usage(bool skipCommandLine,bool indent) const
{
std::ostringstream os;

Expand All @@ -584,7 +588,9 @@ namespace
for (std::deque<help_entry>::const_iterator
iter = argHelps_.begin();iter != argHelps_.end();++iter)
{
os<<'\t'<<iter->first<<std::string(lmax-iter->first.size(),' ')
if(indent)
os<<'\t';
os<<iter->first<<std::string(lmax-iter->first.size(),' ')
<<" : "<<iter->second<<'\n';
}
return os.str();
Expand Down

0 comments on commit e597a03

Please sign in to comment.