merged 2.2 branch

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@7748 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Bryan Petty
2000-07-15 19:51:35 +00:00
parent 8a693e6e04
commit f6bcfd974e
1835 changed files with 237729 additions and 67990 deletions

View File

@@ -485,7 +485,7 @@ int wxCmdLineParser::Parse()
isLong = TRUE;
const wxChar *p = arg.c_str() + 2;
while ( wxIsalpha(*p) || (*p == _T('-')) )
while ( wxIsalnum(*p) || (*p == _T('_')) || (*p == _T('-')) )
{
name += *p++;
}
@@ -503,7 +503,7 @@ int wxCmdLineParser::Parse()
// a short one: as they can be cumulated, we try to find the
// longest substring which is a valid option
const wxChar *p = arg.c_str() + 1;
while ( wxIsalpha(*p) )
while ( wxIsalnum(*p) || (*p == _T('_')) )
{
name += *p++;
}
@@ -596,6 +596,7 @@ int wxCmdLineParser::Parse()
{
switch ( *p )
{
case _T('='):
case _T(':'):
// the value follows
p++;
@@ -619,8 +620,15 @@ int wxCmdLineParser::Parse()
break;
default:
// the value is right here
;
// the value is right here: this may be legal or
// not depending on the option style
if ( opt.flags & wxCMD_LINE_NEEDS_SEPARATOR )
{
wxLogError(_("Separator expected after the option '%s'."),
name.c_str());
ok = FALSE;
}
}
}
@@ -781,9 +789,18 @@ void wxCmdLineParser::Usage()
wxStripExtension(appname);
}
wxString brief, detailed;
// we construct the brief cmd line desc on the fly, but not the detailed
// help message below because we want to align the options descriptions
// and for this we must first know the longest one of them
wxString brief;
wxArrayString namesOptions, descOptions;
brief.Printf(_("Usage: %s"), appname.c_str());
// the switch char is usually '-' but this can be changed with
// SetSwitchChars() and then the first one of possible chars is used
wxChar chSwitch = !m_data->m_switchChars ? _T('-')
: m_data->m_switchChars[0u];
size_t n, count = m_data->m_options.GetCount();
for ( n = 0; n < count; n++ )
{
@@ -795,11 +812,13 @@ void wxCmdLineParser::Usage()
brief << _T('[');
}
brief << _T('-') << opt.shortName;
detailed << _T(" -") << opt.shortName;
brief << chSwitch << opt.shortName;
wxString option;
option << _T(" ") << chSwitch << opt.shortName;
if ( !!opt.longName )
{
detailed << _T(" --") << opt.longName;
option << _T(" --") << opt.longName;
}
if ( opt.kind != wxCMD_LINE_SWITCH )
@@ -807,7 +826,7 @@ void wxCmdLineParser::Usage()
wxString val;
val << _T('<') << GetTypeName(opt.type) << _T('>');
brief << _T(' ') << val;
detailed << (!opt.longName ? _T(':') : _T('=')) << val;
option << (!opt.longName ? _T(':') : _T('=')) << val;
}
if ( !(opt.flags & wxCMD_LINE_OPTION_MANDATORY) )
@@ -815,7 +834,8 @@ void wxCmdLineParser::Usage()
brief << _T(']');
}
detailed << _T('\t') << opt.description << _T('\n');
namesOptions.Add(option);
descOptions.Add(opt.description);
}
count = m_data->m_paramDesc.GetCount();
@@ -848,6 +868,27 @@ void wxCmdLineParser::Usage()
}
wxLogMessage(brief);
// now construct the detailed help message
size_t len, lenMax = 0;
count = namesOptions.GetCount();
for ( n = 0; n < count; n++ )
{
len = namesOptions[n].length();
if ( len > lenMax )
lenMax = len;
}
wxString detailed;
for ( n = 0; n < count; n++ )
{
len = namesOptions[n].length();
detailed << namesOptions[n]
<< wxString(_T(' '), lenMax - len) << _T('\t')
<< descOptions[n]
<< _T('\n');
}
wxLogMessage(detailed);
}