File tree Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Expand file tree Collapse file tree 2 files changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -173,13 +173,13 @@ impl Arguments {
173
173
true
174
174
} else {
175
175
#[ cfg( feature = "combined-flags" ) ]
176
- // Combined flags only work of the short flag is a single character
176
+ // Combined flags only work if the short flag is a single character
177
177
{
178
178
if keys. first ( ) . len ( ) == 2 {
179
179
let short_flag = & keys. first ( ) [ 1 ..2 ] ;
180
180
for ( n, item) in self . 0 . iter ( ) . enumerate ( ) {
181
181
if let Some ( s) = item. to_str ( ) {
182
- if s. starts_with ( '-' ) && s. contains ( short_flag) {
182
+ if s. starts_with ( '-' ) && !s . starts_with ( "--" ) && s. contains ( short_flag) {
183
183
if s. len ( ) == 2 {
184
184
// last flag
185
185
self . 0 . remove ( n) ;
Original file line number Diff line number Diff line change @@ -230,6 +230,21 @@ fn combined_flags_leftover() {
230
230
assert_eq ! ( args. finish( ) , vec![ OsString :: from( "-b" ) ] ) ;
231
231
}
232
232
233
+ #[ test]
234
+ fn long_flag_with_character_from_short_flag ( ) {
235
+ let mut args = Arguments :: from_vec ( to_vec ( & [ "--version" ] ) ) ;
236
+ assert ! ( !args. contains( "-s" ) ) ;
237
+ assert ! ( args. contains( "--version" ) ) ;
238
+ }
239
+
240
+ #[ cfg( feature = "combined-flags" ) ]
241
+ #[ test]
242
+ fn combined_long_flag_with_character_from_short_flag ( ) {
243
+ let mut args = Arguments :: from_vec ( to_vec ( & [ "--version" ] ) ) ;
244
+ assert ! ( !args. contains( "-s" ) ) ;
245
+ assert ! ( args. contains( "--version" ) ) ;
246
+ }
247
+
233
248
#[ cfg( feature = "short-space-opt" ) ]
234
249
#[ test]
235
250
fn space_option_01 ( ) {
You can’t perform that action at this time.
0 commit comments