Merge pull request #560 from kbknapp/issue-558

Issue 558
diff --git a/CHANGELOG.md b/CHANGELOG.md
index ada4d03..c8343c5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -16,6 +16,10 @@
   *  completions now continue completing even after first completion ([18fc2e5b](https://github.com/kbknapp/clap-rs/commit/18fc2e5b5af63bf54a94b72cec5e1223d49f4806))
   *  allows matching on possible values in options ([89cc2026](https://github.com/kbknapp/clap-rs/commit/89cc2026ba9ac69cf44c5254360bbf99236d4f89), closes [#557](https://github.com/kbknapp/clap-rs/issues/557))
 
+#### Bug Fixes
+
+* **AllowLeadingHyphen:**  fixes an issue where  isn't ignored like it should be with this setting ([96c24c9a](https://github.com/kbknapp/clap-rs/commit/96c24c9a8fa1f85e06138d3cdd133e51659e19d2), closes [#558](https://github.com/kbknapp/clap-rs/issues/558))
+
 <a name="v2.8.0"></a>
 ## v2.8.0 (2016-06-30)
 
diff --git a/README.md b/README.md
index b57cad2..2630409 100644
--- a/README.md
+++ b/README.md
@@ -42,6 +42,7 @@
 Here's the highlights for v2.9.0
 
 * **Completions:**  one can now [generate a bash completions](http://kbknapp.github.io/clap-rs/clap/struct.App.html#method.gen_completions) script at compile time! These completions work with options using [possible values](http://kbknapp.github.io/clap-rs/clap/struct.Arg.html#method.possible_values), [subcommand aliases](http://kbknapp.github.io/clap-rs/clap/struct.App.html#method.aliases), and even multiple levels of subcommands
+* Minor bug fixes when using `AppSettings::TrailingVarArg` and `AppSettings::AllowLeadingHyphen`
 
 Here's the highlights for v2.8.0
 
diff --git a/src/app/parser.rs b/src/app/parser.rs
index 29cdfbc..4026a9f 100644
--- a/src/app/parser.rs
+++ b/src/app/parser.rs
@@ -586,7 +586,9 @@
                     }
 
                     needs_val_of = try!(self.parse_long_arg(matcher, &arg_os));
-                    continue;
+                    if !(needs_val_of.is_none() && self.is_set(AppSettings::AllowLeadingHyphen)) {
+                        continue;
+                    }
                 } else if arg_os.starts_with(b"-") && arg_os.len_() != 1 {
                     needs_val_of = try!(self.parse_short_arg(matcher, &arg_os));
                     if !(needs_val_of.is_none() && self.is_set(AppSettings::AllowLeadingHyphen)) {
@@ -1176,6 +1178,8 @@
             arg_post_processing!(self, flag, matcher);
 
             return Ok(None);
+        } else if self.is_set(AppSettings::AllowLeadingHyphen) {
+            return Ok(None);
         }
 
         debugln!("Didn't match anything");
diff --git a/tests/app_settings.rs b/tests/app_settings.rs
index 8b2ed55..24d4ebf 100644
--- a/tests/app_settings.rs
+++ b/tests/app_settings.rs
@@ -234,3 +234,16 @@
     assert!(m.is_present("opt"));
     assert_eq!(m.values_of("opt").unwrap().collect::<Vec<_>>(), &["test", "--foo", "-Wl", "-bar"]);
 }
+
+#[test]
+fn leading_double_hyphen_trailingvararg() {
+    let m = App::new("positional")
+        .setting(AppSettings::TrailingVarArg)
+        .setting(AppSettings::AllowLeadingHyphen)
+        .arg(
+            Arg::from_usage("[opt]... 'some pos'"),
+        )
+        .get_matches_from(vec!["", "--foo", "-Wl", "bar"]);
+    assert!(m.is_present("opt"));
+    assert_eq!(m.values_of("opt").unwrap().collect::<Vec<_>>(), &["--foo", "-Wl", "bar"]);
+}