From: Jean Privat Date: Fri, 21 Mar 2014 00:43:20 +0000 (-0400) Subject: toolcontext: add `usage` and `tooldescription` X-Git-Tag: v0.6.5~14^2~5 X-Git-Url: http://nitlanguage.org?hp=ddba2c37056bfea52d82817f5dc74c6649e1f0b8 toolcontext: add `usage` and `tooldescription` Signed-off-by: Jean Privat --- diff --git a/src/toolcontext.nit b/src/toolcontext.nit index ba080e3..b91fdad 100644 --- a/src/toolcontext.nit +++ b/src/toolcontext.nit @@ -171,6 +171,22 @@ class ToolContext option_context.add_option(opt_warn, opt_quiet, opt_stop_on_first_error, opt_no_color, opt_log, opt_log_dir, opt_help, opt_version, opt_verbose) end + # Name, usage and synopsis of the tool. + # It is mainly used in `usage`. + # Should be correctly set by the client before calling `process_options` + # A multi-line string is recommmended. + # + # eg. `"Usage: tool [OPTION]... [FILE]...\nDo some things."` + var tooldescription: String writable = "Usage: [OPTION]... [ARG]..." + + # print the full usage of the tool. + # It also could be called by the client. + fun usage + do + print tooldescription + option_context.usage + end + # Parse and process the options given on the command line fun process_options do