]> granicus.if.org Git - llvm/commitdiff
[Bash-autocompletion] Show HelpText with possible flags
authorYuka Takahashi <yukatkh@gmail.com>
Wed, 26 Jul 2017 13:36:58 +0000 (13:36 +0000)
committerYuka Takahashi <yukatkh@gmail.com>
Wed, 26 Jul 2017 13:36:58 +0000 (13:36 +0000)
Summary:
`clang --autocomplete=-std` will show
```
-std:   Language standard to compile for
-std=   Language standard to compile for
-stdlib=        C++ standard library to use
```
after this change.

However, showing HelpText with completion in bash seems super tricky, so
this feature will be used in other shells (fish, zsh...).

Reviewers: v.g.vassilev, teemperor, ruiu

Subscribers: cfe-commits, hiraditya

Differential Revision: https://reviews.llvm.org/D35759

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@309113 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Option/OptTable.cpp

index 071c9db87206e283dd1ff7be3d5022b86dbd1db0..7910bea0dcc2ecb97a03e31387814439a11fc8fa 100644 (file)
@@ -235,7 +235,9 @@ OptTable::findByPrefix(StringRef Cur, unsigned short DisableFlags) const {
       continue;
 
     for (int I = 0; In.Prefixes[I]; I++) {
-      std::string S = std::string(In.Prefixes[I]) + std::string(In.Name);
+      std::string S = std::string(In.Prefixes[I]) + std::string(In.Name) + "\t";
+      if (In.HelpText)
+        S += In.HelpText;
       if (StringRef(S).startswith(Cur))
         Ret.push_back(S);
     }