little improvement to command line help display

This commit is contained in:
csoler 2017-07-09 22:12:01 +02:00
parent 2c6f11e4eb
commit 3e3ee1a34b
2 changed files with 14 additions and 9 deletions

View File

@ -89,6 +89,7 @@
// #define GPG_DEBUG
// #define AUTHSSL_DEBUG
// #define FIM_DEBUG
// #define DEBUG_RSINIT
//std::map<std::string,std::vector<std::string> > RsInit::unsupported_keys ;
@ -311,8 +312,10 @@ int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */)
argc = i;
#endif
#ifdef DEBUG_RSINIT
for(int i=0; i<argc; i++)
printf("%d: %s\n", i, argv[i]);
#endif
/* for static PThreads under windows... we need to init the library... */
#ifdef PTW32_STATIC_LIB
@ -357,7 +360,7 @@ int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */)
>> parameter('i',"ip-address" ,rsInitConfig->inet ,"nnn.nnn.nnn.nnn", "Set IP address to use." ,false)
>> parameter('p',"port" ,rsInitConfig->port ,"port", "Set listenning port to use." ,false)
>> parameter('c',"base-dir" ,opt_base_dir ,"directory", "Set base directory." ,false)
>> parameter('U',"user-id" ,prefUserString ,"ID", "[User Name/GPG id/SSL id] Sets Account to Use, Useful when Autologin is enabled",false)
>> parameter('U',"user-id" ,prefUserString ,"ID", "[ocation Id] Sets Account to Use, Useful when Autologin is enabled.",false)
// by rshare 'r' "link" "Link" "Open RsLink with protocol retroshare://"
// by rshare 'f' "rsfile" "RsFile" "Open RsFile like RsCollection"
#ifdef LOCALNET_TESTING
@ -365,7 +368,7 @@ int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */)
#endif
>> help('h',"help","Display this Help") ;
as.defaultErrorHandling(true) ;
as.defaultErrorHandling(true,true) ;
if(rsInitConfig->autoLogin) rsInitConfig->startMinimised = true ;
if(rsInitConfig->outStderr) rsInitConfig->haveLogFile = false ;
@ -472,7 +475,7 @@ int RsInit::InitRetroShare(int argc, char **argv, bool /* strictCheck */)
{
if (!rsAccounts->selectAccountByString(prefUserString))
{
std::cerr << "Invalid User name/GPG id/SSL id: not found in list";
std::cerr << "Invalid User location id: not found in list";
std::cerr << std::endl;
return RS_INIT_AUTH_FAILED ;
}

View File

@ -252,8 +252,8 @@ namespace
inline bool helpRequested() const;
inline bool isOk() const;
inline std::string errorLog() const;
inline std::string usage() const;
inline bool defaultErrorHandling(bool ignoreUnused=false) const;
inline std::string usage(bool skipCommandLine = false) const;
inline bool defaultErrorHandling(bool ignoreUnused=false,bool skipCommandLine=false) const;
static inline char uniqueLetter();
protected:
void parse(int argc,char** argv);
@ -569,10 +569,12 @@ namespace
return helpRequested_;
}
inline std::string
argstream::usage() const
argstream::usage(bool skipCommandLine) const
{
std::ostringstream os;
os<<"usage: "<<progName_<<cmdLine_<<'\n';
if(!skipCommandLine)
os<<"usage: "<<progName_<<cmdLine_<<'\n';
unsigned int lmax = 0;
for (std::deque<help_entry>::const_iterator
iter = argHelps_.begin();iter != argHelps_.end();++iter)
@ -820,11 +822,11 @@ namespace
return s;
}
inline bool
argstream::defaultErrorHandling(bool ignoreUnused) const
argstream::defaultErrorHandling(bool ignoreUnused,bool skipCommandLine) const
{
if (helpRequested_)
{
std::cout<<usage();
std::cout<<usage(skipCommandLine);
exit(1);
}
if (!isOk_)