diff options
author | Mike Buland <eichlan@xagasoft.com> | 2010-01-15 18:30:31 +0000 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2010-01-15 18:30:31 +0000 |
commit | 42f921e3dad53405f67463f57eefd52b095ee11f (patch) | |
tree | 78c8c0308ee5867fa9359a679daa0680a8d62995 /src/optparser.cpp | |
parent | 5471d34089277ad5c622fd9c392b9270229d9e3d (diff) | |
download | libbu++-42f921e3dad53405f67463f57eefd52b095ee11f.tar.gz libbu++-42f921e3dad53405f67463f57eefd52b095ee11f.tar.bz2 libbu++-42f921e3dad53405f67463f57eefd52b095ee11f.tar.xz libbu++-42f921e3dad53405f67463f57eefd52b095ee11f.zip |
Documented more of MiniCron, and added some cool new help features to OptParser.
Diffstat (limited to '')
-rw-r--r-- | src/optparser.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/src/optparser.cpp b/src/optparser.cpp index 14e7418..081b26c 100644 --- a/src/optparser.cpp +++ b/src/optparser.cpp | |||
@@ -179,6 +179,11 @@ void Bu::OptParser::setOverride( const Bu::FString &sOpt, const Bu::FString &sOv | |||
179 | hlOption.get( sOpt )->sOverride = sOverride; | 179 | hlOption.get( sOpt )->sOverride = sOverride; |
180 | } | 180 | } |
181 | 181 | ||
182 | void Bu::OptParser::setHelpDefault( const Bu::FString &sOpt, const Bu::FString &sTxt ) | ||
183 | { | ||
184 | hlOption.get( sOpt )->sHelpDefault = sTxt; | ||
185 | } | ||
186 | |||
182 | void Bu::OptParser::addHelpOption( char c, const Bu::FString &s, const Bu::FString &sHelp ) | 187 | void Bu::OptParser::addHelpOption( char c, const Bu::FString &s, const Bu::FString &sHelp ) |
183 | { | 188 | { |
184 | Option o; | 189 | Option o; |
@@ -213,8 +218,9 @@ int Bu::OptParser::optHelp( StrArray /*aParams*/ ) | |||
213 | { | 218 | { |
214 | if( (*i).cOpt != '\0' ) | 219 | if( (*i).cOpt != '\0' ) |
215 | bHasShort = true; | 220 | bHasShort = true; |
216 | if( (*i).sOpt && iMaxWidth < (*i).sOpt.getSize() ) | 221 | int lOptSize = (*i).sOpt.getSize() + (*i).sHelpDefault.getSize(); |
217 | iMaxWidth = (*i).sOpt.getSize(); | 222 | if( (*i).sOpt && iMaxWidth < lOptSize ) |
223 | iMaxWidth = lOptSize; | ||
218 | } | 224 | } |
219 | int iIndent = 4; | 225 | int iIndent = 4; |
220 | if( bHasShort ) | 226 | if( bHasShort ) |
@@ -249,7 +255,8 @@ int Bu::OptParser::optHelp( StrArray /*aParams*/ ) | |||
249 | { | 255 | { |
250 | if( (*i).sOpt ) | 256 | if( (*i).sOpt ) |
251 | { | 257 | { |
252 | sio << "--" << Fmt(iMaxWidth, Fmt::Left) << (*i).sOpt; | 258 | sio << "--" << Fmt(iMaxWidth, Fmt::Left) |
259 | << (*i).sOpt + (*i).sHelpDefault; | ||
253 | } | 260 | } |
254 | else | 261 | else |
255 | { | 262 | { |