diff options
Diffstat (limited to 'src/optparser.cpp')
-rw-r--r-- | src/optparser.cpp | 57 |
1 files changed, 56 insertions, 1 deletions
diff --git a/src/optparser.cpp b/src/optparser.cpp index 2a8e64b..d656e12 100644 --- a/src/optparser.cpp +++ b/src/optparser.cpp | |||
@@ -106,6 +106,14 @@ void Bu::OptParser::parse( int argc, char **argv ) | |||
106 | ); | 106 | ); |
107 | break; | 107 | break; |
108 | } | 108 | } |
109 | else if( argv[j+1] ) | ||
110 | { | ||
111 | pOpt->pProxy->setValue( | ||
112 | argv[j+1] | ||
113 | ); | ||
114 | j++; | ||
115 | break; | ||
116 | } | ||
109 | } | 117 | } |
110 | } | 118 | } |
111 | else | 119 | else |
@@ -135,6 +143,16 @@ void Bu::OptParser::addOption( const Option &opt ) | |||
135 | hlOption.insert( opt.sOpt, &lOption.last() ); | 143 | hlOption.insert( opt.sOpt, &lOption.last() ); |
136 | } | 144 | } |
137 | 145 | ||
146 | void Bu::OptParser::setOverride( char cOpt, const Bu::FString &sOverride ) | ||
147 | { | ||
148 | hsOption.get( cOpt )->sOverride = sOverride; | ||
149 | } | ||
150 | |||
151 | void Bu::OptParser::setOverride( const Bu::FString &sOpt, const Bu::FString &sOverride ) | ||
152 | { | ||
153 | hlOption.get( sOpt )->sOverride = sOverride; | ||
154 | } | ||
155 | |||
138 | void Bu::OptParser::addHelpOption( char c, const Bu::FString &s, const Bu::FString &sHelp ) | 156 | void Bu::OptParser::addHelpOption( char c, const Bu::FString &s, const Bu::FString &sHelp ) |
139 | { | 157 | { |
140 | Option o; | 158 | Option o; |
@@ -146,7 +164,19 @@ void Bu::OptParser::addHelpOption( char c, const Bu::FString &s, const Bu::FStri | |||
146 | addOption( o ); | 164 | addOption( o ); |
147 | } | 165 | } |
148 | 166 | ||
149 | int Bu::OptParser::optHelp( StrArray aParams ) | 167 | void Bu::OptParser::addHelpBanner( const Bu::FString &sText, bool bFormatted ) |
168 | { | ||
169 | Banner b; | ||
170 | b.sText = sText; | ||
171 | b.bFormatted = bFormatted; | ||
172 | if( lOption.getSize() > 0 ) | ||
173 | { | ||
174 | for( b.iAfter = lOption.begin(); b.iAfter+1; b.iAfter++ ) { } | ||
175 | } | ||
176 | lBanner.append( b ); | ||
177 | } | ||
178 | |||
179 | int Bu::OptParser::optHelp( StrArray /*aParams*/ ) | ||
150 | { | 180 | { |
151 | bool bHasShort = false; | 181 | bool bHasShort = false; |
152 | int iMaxWidth = 0; | 182 | int iMaxWidth = 0; |
@@ -166,6 +196,19 @@ int Bu::OptParser::optHelp( StrArray aParams ) | |||
166 | iIndent += 4; | 196 | iIndent += 4; |
167 | if( iMaxWidth > 0 ) | 197 | if( iMaxWidth > 0 ) |
168 | iIndent += 4 + iMaxWidth; | 198 | iIndent += 4 + iMaxWidth; |
199 | |||
200 | BannerList::iterator iBanner; | ||
201 | for( iBanner = lBanner.begin(); iBanner; iBanner++ ) | ||
202 | { | ||
203 | if( (*iBanner).iAfter ) | ||
204 | break; | ||
205 | |||
206 | if( (*iBanner).bFormatted ) | ||
207 | sio << format( (*iBanner).sText, iScrWidth-1, 0 ); | ||
208 | else | ||
209 | sio << (*iBanner).sText; | ||
210 | sio << sio.nl; | ||
211 | } | ||
169 | for( OptionList::iterator i = lOption.begin(); i; i++ ) | 212 | for( OptionList::iterator i = lOption.begin(); i; i++ ) |
170 | { | 213 | { |
171 | sio << " "; | 214 | sio << " "; |
@@ -191,6 +234,18 @@ int Bu::OptParser::optHelp( StrArray aParams ) | |||
191 | } | 234 | } |
192 | sio << format( (*i).sHelp, iScrWidth-iIndent-1, iIndent ); | 235 | sio << format( (*i).sHelp, iScrWidth-iIndent-1, iIndent ); |
193 | sio << sio.nl; | 236 | sio << sio.nl; |
237 | |||
238 | for( ; iBanner; iBanner++ ) | ||
239 | { | ||
240 | if( (*iBanner).iAfter != i ) | ||
241 | break; | ||
242 | |||
243 | if( (*iBanner).bFormatted ) | ||
244 | sio << format( (*iBanner).sText, iScrWidth-1, 0 ); | ||
245 | else | ||
246 | sio << (*iBanner).sText; | ||
247 | sio << sio.nl; | ||
248 | } | ||
194 | } | 249 | } |
195 | exit( 0 ); | 250 | exit( 0 ); |
196 | return 0; | 251 | return 0; |