summaryrefslogtreecommitdiff
path: root/src/optparser.cpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/optparser.cpp36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/optparser.cpp b/src/optparser.cpp
index 864d8ce..b81691d 100644
--- a/src/optparser.cpp
+++ b/src/optparser.cpp
@@ -45,7 +45,11 @@ void Bu::OptParser::parse( int argc, char **argv )
45 { 45 {
46 sOpt.set( argv[j]+2 ); 46 sOpt.set( argv[j]+2 );
47 } 47 }
48 try 48 if( !hlOption.has( sOpt ) )
49 {
50 optionError( "--" + sOpt );
51 }
52 else
49 { 53 {
50 // Long param, cool, that's easy, first search for = 54 // Long param, cool, that's easy, first search for =
51 Option *pOpt = hlOption.get( sOpt ); 55 Option *pOpt = hlOption.get( sOpt );
@@ -71,26 +75,28 @@ void Bu::OptParser::parse( int argc, char **argv )
71 } 75 }
72 else if( sExtraParam.isSet() ) 76 else if( sExtraParam.isSet() )
73 { 77 {
74 pOpt->pProxy->setValue( sExtraParam ); 78 pOpt->pProxy->setValueFromStr( sExtraParam );
75 } 79 }
76 else if( argv[j+1] != '\0' ) 80 else if( argv[j+1] != '\0' )
77 { 81 {
78 pOpt->pProxy->setValue( argv[j+1] ); 82 pOpt->pProxy->setValueFromStr( argv[j+1] );
79 j++; 83 j++;
80 } 84 }
81 } 85 }
82 } 86 }
83 catch( Bu::HashException &e )
84 {
85 optionError( "--" + sOpt );
86 }
87 } 87 }
88 else 88 else
89 { 89 {
90 int iCPos; 90 int iCPos;
91 for( iCPos = 1; argv[j][iCPos] != '\0'; iCPos++ ) 91 for( iCPos = 1; argv[j][iCPos] != '\0'; iCPos++ )
92 { 92 {
93 try 93 if( !hsOption.has( argv[j][iCPos] ) )
94 {
95 Bu::FString sOpt("-");
96 sOpt += argv[j][iCPos];
97 optionError( sOpt );
98 }
99 else
94 { 100 {
95 Option *pOpt = hsOption.get( argv[j][iCPos] ); 101 Option *pOpt = hsOption.get( argv[j][iCPos] );
96 char buf[2] = {argv[j][iCPos], '\0'}; 102 char buf[2] = {argv[j][iCPos], '\0'};
@@ -123,14 +129,14 @@ void Bu::OptParser::parse( int argc, char **argv )
123 } 129 }
124 else if( argv[j][iCPos+1] != '\0' ) 130 else if( argv[j][iCPos+1] != '\0' )
125 { 131 {
126 pOpt->pProxy->setValue( 132 pOpt->pProxy->setValueFromStr(
127 argv[j]+iCPos+1 133 argv[j]+iCPos+1
128 ); 134 );
129 break; 135 break;
130 } 136 }
131 else if( argv[j+1] ) 137 else if( argv[j+1] )
132 { 138 {
133 pOpt->pProxy->setValue( 139 pOpt->pProxy->setValueFromStr(
134 argv[j+1] 140 argv[j+1]
135 ); 141 );
136 j++; 142 j++;
@@ -138,12 +144,6 @@ void Bu::OptParser::parse( int argc, char **argv )
138 } 144 }
139 } 145 }
140 } 146 }
141 catch( Bu::HashException &e )
142 {
143 Bu::FString sOpt("-");
144 sOpt += argv[j][iCPos];
145 optionError( sOpt );
146 }
147 } 147 }
148 } 148 }
149 } 149 }
@@ -176,12 +176,12 @@ void Bu::OptParser::addOption( const Option &opt )
176 hlOption.insert( opt.sOpt, &lOption.last() ); 176 hlOption.insert( opt.sOpt, &lOption.last() );
177} 177}
178 178
179void Bu::OptParser::setOverride( char cOpt, const Bu::FString &sOverride ) 179void Bu::OptParser::setOverride( char cOpt, const Bu::Variant &sOverride )
180{ 180{
181 hsOption.get( cOpt )->sOverride = sOverride; 181 hsOption.get( cOpt )->sOverride = sOverride;
182} 182}
183 183
184void Bu::OptParser::setOverride( const Bu::FString &sOpt, const Bu::FString &sOverride ) 184void Bu::OptParser::setOverride( const Bu::FString &sOpt, const Bu::Variant &sOverride )
185{ 185{
186 hlOption.get( sOpt )->sOverride = sOverride; 186 hlOption.get( sOpt )->sOverride = sOverride;
187} 187}