ni: added help message
authorAlexandre Terrasa <alexandre@moz-code.org>
Tue, 30 Jul 2013 15:26:38 +0000 (11:26 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 30 Jul 2013 15:26:38 +0000 (11:26 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/ni.nit

index 4f3ad39..be1e2ef 100644 (file)
@@ -70,11 +70,7 @@ class NitIndex
 
        fun welcome do
                print "Welcome in the Nit Index."
-               print "\nCommands:"
-               print "\tname\t\tlookup module, class and property with the corresponding 'name'"
-               print "\tparam: Type\tlookup methods using the corresponding 'Type' as parameter"
-               print "\treturn: Type\tlookup methods returning the corresponding 'Type'"
-               print "\tEnter ':q' to exit\n"
+               print ""
                print "Loaded modules:"
                var mmodules = new Array[MModule]
                mmodules.add_all(model.mmodules)
@@ -84,6 +80,17 @@ class NitIndex
                        print "\t{m.name}"
                end
                print ""
+               help
+       end
+
+       fun help do
+               print "\nCommands:"
+               print "\tname\t\tlookup module, class and property with the corresponding 'name'"
+               print "\tparam: Type\tlookup methods using the corresponding 'Type' as parameter"
+               print "\treturn: Type\tlookup methods returning the corresponding 'Type'"
+               print "\tEnter ':q' to exit"
+               print "\tEnter ':h' to display this help message"
+               print ""
        end
 
        fun prompt do
@@ -96,6 +103,11 @@ class NitIndex
                        prompt
                        return
                end
+               if entry == ":h" then
+                       help
+                       prompt
+                       return
+               end
                if entry == ":q" then exit(0)
                var pager = new Pager
                # seek return types
@@ -129,7 +141,7 @@ class NitIndex
                end
                # no matches
                if pager.content.is_empty then
-                       print "Nothing known about '{entry}'"
+                       print "Nothing known about '{entry}', type ':h' for help"
                else
                        pager.render
                end