changed the behavior of completing short option names

- previously it would return only a list of short option names
- now it returns both short and long option names; in the case when an
option has both a short and long name, it will return only the long name

Signed-off-by: Nick Wei <nwei@pivotal.io>
diff --git a/completion.go b/completion.go
index 708fa9e..f6a094d 100644
--- a/completion.go
+++ b/completion.go
@@ -101,7 +101,30 @@
 		}
 	}
 
-	return c.completeOptionNames(s.lookup.shortNames, prefix, match)
+	var results []Completion
+	repeats := map[string]bool{}
+
+	for name, opt := range s.lookup.longNames {
+		if !opt.Hidden {
+			results = append(results, Completion{
+				Item:        "--" + name,
+				Description: opt.Description,
+			})
+
+			repeats[string(opt.ShortName)] = true
+		}
+	}
+
+	for name, opt := range s.lookup.shortNames {
+		if _, exist := repeats[name]; !exist && !opt.Hidden {
+			results = append(results, Completion{
+				Item:        "-" + name,
+				Description: opt.Description,
+			})
+		}
+	}
+
+	return results
 }
 
 func (c *completion) completeCommands(s *parseState, match string) []Completion {
diff --git a/completion_test.go b/completion_test.go
index 72ee158..271d18c 100644
--- a/completion_test.go
+++ b/completion_test.go
@@ -38,6 +38,7 @@
 var completionTestOptions struct {
 	Verbose  bool `short:"v" long:"verbose" description:"Verbose messages"`
 	Debug    bool `short:"d" long:"debug" description:"Enable debug"`
+	Info     bool `short:"i" description:"Display info"`
 	Version  bool `long:"version" description:"Show version"`
 	Required bool `long:"required" required:"true" description:"This is required"`
 	Hidden   bool `long:"hidden" hidden:"true" description:"This is hidden"`
@@ -82,7 +83,7 @@
 		{
 			// Short names
 			[]string{"-"},
-			[]string{"-d", "-v"},
+			[]string{"--debug", "--required", "--verbose", "--version", "-i"},
 			false,
 		},