]> khamidou — GitHub mirrors - arcanist.git/commitdiff
Improve bash completion for commands like 'arc lint' and 'arc unit'.
authorepriestley <epriestley@javelinjs.com>
Wed, 16 Feb 2011 19:51:06 +0000 (11:51 -0800)
committerepriestley <epriestley@javelinjs.com>
Wed, 16 Feb 2011 19:51:06 +0000 (11:51 -0800)
Summary:

Test Plan:

Reviewers:

CC:

src/workflow/shell-complete/ArcanistShellCompleteWorkflow.php

index 6b1177610c1ebc7739e604b5d3f7e949e59ed40f..9ce06663e21012b429458ff462feee64ca68534b 100644 (file)
@@ -123,6 +123,7 @@ EOTEXT
         }
         return 0;
       } else {
+        
         $output = array();
         foreach ($arguments as $argument => $spec) {
           if ($argument == '*') {
@@ -135,8 +136,23 @@ EOTEXT
           }
           $output[] = '--'.$argument;
         }
-
-        echo implode(' ', $output)."\n";
+        
+        $cur = idx($argv, $pos, '');
+        $any_match = false;
+        foreach ($output as $possible) {
+          if (!strncmp($possible, $cur, strlen($cur))) {
+            $any_match = true;
+          }
+        }
+        
+        if (!$any_match && isset($arguments['*'])) {
+          // TODO: the '*' specifier should probably have more details about
+          // whether or not it is a list of files. Since it almost always is in
+          // practice, assume FILE for now.
+          echo "FILE\n";
+        } else {
+          echo implode(' ', $output)."\n";
+        }
         return 0;
       }
     }