<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -1,6 +1,7 @@
-module Usage (fromFile) where
+module Usage (Environment, commands, fromFile, lookupCommand) where
 
 import qualified Completer as C
+import Data.List (nub, sort)
 import Text.ParserCombinators.Parsec
 import Text.ParserCombinators.Parsec.Language (javaStyle)
 import qualified Text.ParserCombinators.Parsec.Token as T
@@ -12,11 +13,11 @@ data Usage = Primitive C.Completer | Var String
              | Choice [Usage] | Sequence [Usage]
              | Many Usage | Many1 Usage | Optional Usage
 
-fromFile :: String -&gt; String -&gt; IO C.Completer
-fromFile fileName command = do
+fromFile :: String -&gt; IO Environment
+fromFile fileName = do
     result &lt;- parseFromFile usage fileName
     case result of
-        Right env -&gt; return (run env command)
+        Right env -&gt; return env
         Left err  -&gt; error (show err)
 
 -- Evaluator
@@ -25,8 +26,8 @@ type Environment = [(EnvName,Usage)] -- Associates variables with values.
 data EnvName = VarName String | CommandName String
     deriving Eq
 
-run :: Environment -&gt; String -&gt; C.Completer
-run env command = eval env (main env)
+lookupCommand :: Environment -&gt; String -&gt; C.Completer
+lookupCommand env command = eval env (main env)
     where main env = Choice $ map snd $ filter ((CommandName command ==) . fst) env
 
 eval :: Environment -&gt; Usage -&gt; C.Completer
@@ -40,6 +41,9 @@ eval env (Var s)       = case lookup (VarName s) env of
                             Just u  -&gt; eval env u
                             Nothing -&gt; C.skip
 
+commands :: Environment -&gt; [String]
+commands env = nub $ sort [s | (CommandName s, _) &lt;- env]
+
 -- Top-level parser
 
 usage :: Parser Environment</diff>
      <filename>Usage.hs</filename>
    </modified>
    <modified>
      <diff>@@ -3,13 +3,22 @@ import Numeric (readDec)
 import System (getArgs)
 import System.Environment (getEnv)
 import Tokenize (tokenize)
-import Usage (fromFile)
+import Usage (Environment, commands, fromFile, lookupCommand)
 
+-- Parse the usage file from the first argument.  If there is a second argument,
+-- it is a command-name; find the usage rules for that command and use them to
+-- complete the input line.  Otherwise, list all command names in the usage file.
 main = do
-    line &lt;- getInput
     args &lt;- getArgs
-    let command = args !! 1
-    completer &lt;- fromFile (head args) command
+    env &lt;- fromFile (head args)
+    if length args &gt; 1
+        then completeLine env (args !! 1)
+        else listCommands env
+
+completeLine :: Environment -&gt; String -&gt; IO ()
+completeLine env command = do
+    line &lt;- getInput
+    let completer = lookupCommand env command
     suggestions &lt;- run completer (tokenize line)
     mapM_ putStrLn suggestions
 
@@ -19,3 +28,6 @@ getInput = do
     point &lt;- getEnv &quot;COMP_POINT&quot;
     let [(n,[])] = readDec point
     return (take n line)
+
+listCommands :: Environment -&gt; IO ()
+listCommands = mapM_ putStrLn . commands</diff>
      <filename>compleat.hs</filename>
    </modified>
    <modified>
      <diff>@@ -4,8 +4,9 @@
 for DIR in $COMPLEAT_SYSTEM_DIR $COMPLEAT_USER_DIR; do
     if [ -d $DIR -a -r $DIR -a -x $DIR ]; then
         for FILE in $DIR/*.usage; do
-            COMMAND=`basename $FILE .usage`
-            complete -o nospace -o default -C &quot;compleat $FILE&quot; $COMMAND
+            for COMMAND in `compleat $FILE`; do
+                complete -o nospace -o default -C &quot;compleat $FILE&quot; $COMMAND
+            done
         done
     fi
 done</diff>
      <filename>compleat_setup</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>0313d3ca33f0b9f448a8f1542d2d06ca80f36c0e</id>
    </parent>
  </parents>
  <author>
    <name>Matt Brubeck</name>
    <email>mbrubeck@limpet.net</email>
  </author>
  <url>http://github.com/mbrubeck/compleat/commit/1d58f7bf979d46f6666d1cddc72ab76987824f19</url>
  <id>1d58f7bf979d46f6666d1cddc72ab76987824f19</id>
  <committed-date>2009-10-29T06:47:22-07:00</committed-date>
  <authored-date>2009-10-29T06:47:22-07:00</authored-date>
  <message>Allow multiple command names per file.</message>
  <tree>17ea57f71f0d2ec88fc7abbaa5bd4814a69b71d7</tree>
  <committer>
    <name>Matt Brubeck</name>
    <email>mbrubeck@limpet.net</email>
  </committer>
</commit>
