tools: programs know their names
authorJean Privat <jean@pryen.org>
Fri, 26 Jun 2009 04:53:21 +0000 (00:53 -0400)
committerJean Privat <jean@pryen.org>
Fri, 26 Jun 2009 05:06:51 +0000 (01:06 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/abstracttool.nit
src/nitc.nit
src/nitdoc.nit

index 3d4d80e..756117a 100644 (file)
@@ -25,22 +25,29 @@ import syntax
 class AbstractCompiler
 special ToolContext
 
-       init
+       init(tool_name: String)
        do
+               _tool_name = tool_name
                super
                register_loader(new SrcModuleLoader)
        end
 
+       # The name of the tool
+       # Used in help messages for instance
+       readable attr _tool_name: String
+
        meth exec_cmd_line
        do
                process_options
 
                if opt_help.value then
+                       print "usage: {tool_name} [options] file..."
                        option_context.usage
                        exit(0)
                end
 
                if option_context.rest.length == 0 then
+                       print "usage: {tool_name} [options] file..."
                        option_context.usage
                        exit(1)
                end
index 087793d..604431e 100644 (file)
@@ -34,7 +34,7 @@ special AbstractCompiler
 
        init
        do
-               super
+               super("nitc")
                option_context.add_option(opt_output, opt_boost, opt_no_cc, opt_global, opt_clibdir, opt_bindir, opt_compdir, opt_extension_prefix)
        end
 
index 4c98a84..18e1d0c 100644 (file)
@@ -247,7 +247,7 @@ special AbstractCompiler
 
        init
        do
-               super
+               super("nitdoc")
                option_context.add_option(opt_dir)
        end