do
# Create a tool context to handle options and paths
toolcontext = new ToolContext
+ toolcontext.tooldescription = "Usage: nit [OPTION]... <file.nit>...\nInterprets and debbugs Nit programs."
# Add an option "-o" to enable compatibilit with the tests.sh script
var opt = new OptionString("compatibility (does noting)", "-o")
toolcontext.option_context.add_option(opt)
modelbuilder = new ModelBuilder(model, toolcontext.as(not null))
arguments = toolcontext.option_context.rest
- if arguments.is_empty or toolcontext.opt_help.value then
- toolcontext.option_context.usage
- exit(0)
- end
var progname = arguments.first
# Here we load an process all modules passed on the command line
# Create a tool context to handle options and paths
var toolcontext = new ToolContext
+toolcontext.tooldescription = "Usage: nitdbg_client [OPTION]...\nConnects to a nitdbg_server and controls it."
+toolcontext.accept_no_arguments = true
toolcontext.process_options
var debug: DebugClient
-if toolcontext.opt_help.value then
- toolcontext.option_context.usage
- return
-end
-
# If the port value is not an Int between 0 and 65535 (Mandatory according to the norm)
# Print the usage
if toolcontext.opt_debug_port.value < 0 or toolcontext.opt_debug_port.value > 65535 then
toolcontext.option_context.add_option(opt_github_gitdir)
toolcontext.option_context.add_option(opt_piwik_tracker)
toolcontext.option_context.add_option(opt_piwik_site_id)
+ toolcontext.tooldescription = "Usage: nitdoc [OPTION]... <file.nit>...\nGenerates HTML pages of API documentation from Nit source files."
toolcontext.process_options
self.arguments = toolcontext.option_context.rest
- if arguments.length < 1 then
- print "usage: nitdoc [options] file..."
- toolcontext.option_context.usage
- exit(0)
- end
self.process_options
model = new Model
var opt_mixins = new OptionArray("Additionals module to min-in", "-m")
toolcontext.option_context.add_option(opt_mixins)
+toolcontext.tooldescription = "Usage: nitg [OPTION]... file.nit\nCompiles Nit programs."
+
# We do not add other options, so process them now!
toolcontext.process_options
var modelbuilder = new ModelBuilder(model, toolcontext)
var arguments = toolcontext.option_context.rest
-if arguments.is_empty then
- toolcontext.option_context.usage
- return
-end
if arguments.length > 1 then
print "Too much arguments: {arguments.join(" ")}"
- toolcontext.option_context.usage
- return
+ print toolcontext.tooldescription
+ exit 1
end
var progname = arguments.first
var opt_full = new OptionBool("Process also imported modules", "--full")
var opt_ast = new OptionBool("Generate specific HTML elements for each Node of the AST", "--ast")
toolcontext.option_context.add_option(opt_fragment, opt_first_line, opt_last_line, opt_dir, opt_full)
+toolcontext.tooldescription = "Usage: nitlight [OPTION]... <file.nit>...\nGenerates HTML of highlited code from Nit source files."
var model = new Model
var modelbuilder = new ModelBuilder(model, toolcontext)
toolcontext.process_options
var args = toolcontext.option_context.rest
-if args.is_empty then
- print "usage: nitlight [options] files..."
- toolcontext.option_context.usage
- return
-end
-
var mmodules = modelbuilder.parse(args)
modelbuilder.run_phases
var opt_depends = new OptionBool("List dependencies of given modules", "-M", "--depends")
tc.option_context.add_option(opt_keep, opt_recursive, opt_tree, opt_source, opt_project, opt_depends)
-
+tc.tooldescription = "Usage: nitls [OPTION]... <file.nit|directory>...\nLists the projects and/or paths of Nit sources files."
tc.process_options
var sum = opt_tree.value.to_i + opt_source.value.to_i + opt_project.value.to_i + opt_depends.value.to_i
-if sum > 1 or tc.option_context.rest.is_empty or tc.opt_help.value then
- print "Usage: nitls [OPTION].. [FILES]..."
- print "List Nit source files"
- tc.option_context.usage
- exit 0
+if sum > 1 then
+ print "Error: options --tree, --source, and --project are exclusives."
+ print tc.tooldescription
+ exit 1
end
if opt_depends.value then
# Create a tool context to handle options and paths
var toolcontext = new ToolContext
+toolcontext.tooldescription = "Usage: nitmetrics [OPTION]... <file.nit>...\mComputes various metrics on Nit programs."
+
# We do not add other options, so process them now!
toolcontext.process_options
# Get arguments
var arguments = toolcontext.option_context.rest
-if arguments.is_empty or toolcontext.opt_help.value then
- toolcontext.option_context.usage
- return
-end
# We need a model to collect stufs
var model = new Model
var toolcontext = new ToolContext
toolcontext.option_context.add_option(toolcontext.opt_full, toolcontext.opt_output, toolcontext.opt_dir)
-
+toolcontext.tooldescription = "Usage: nitunit [OPTION]... <file.nit>...\nExecutes the unit tests from Nit source files."
toolcontext.process_options
var args = toolcontext.option_context.rest
-if args.is_empty or toolcontext.opt_help.value then
- print "usage: nitunit [options] file.nit..."
- toolcontext.option_context.usage
- return
-end
var model = new Model
var modelbuilder = new ModelBuilder(model, toolcontext)
init(toolcontext: ToolContext) do
# We need a model to collect stufs
self.toolcontext = toolcontext
- self.toolcontext.option_context.options.clear
self.arguments = toolcontext.option_context.rest
- if arguments.is_empty or arguments.length > 2 then
- print "usage: ni path/to/module.nit [expression]"
- toolcontext.option_context.usage
+ if arguments.length > 2 then
+ print toolcontext.tooldescription
exit(1)
end
# Create a tool context to handle options and paths
var toolcontext = new ToolContext
+toolcontext.tooldescription = "Usage: nitx [OPTION]... <file.nit> [query]\nDisplays specific pieces of API information from Nit source files."
toolcontext.process_options
# Here we launch the nit index
var opt_full = new OptionBool("Process also imported modules", "--full")
toolcontext.option_context.add_option(opt_full)
+toolcontext.tooldescription = "Usage: test_markdown [OPTION]... <file.nit>...\nGenerates HTML of comments of documentation from Nit source files."
toolcontext.process_options
var args = toolcontext.option_context.rest
-if args.is_empty then
- print "usage: test_markdown [options] file.nit..."
- toolcontext.option_context.usage
- return
-end
var model = new Model
var modelbuilder = new ModelBuilder(model, toolcontext)
# Create a tool context to handle options and paths
var toolcontext = new ToolContext
+toolcontext.tooldescription = "Usage: [OPTION]... <file.nit>..."
+
# We do not add other options, so process them now!
toolcontext.process_options
# Get arguments
var arguments = toolcontext.option_context.rest
-if arguments.is_empty or toolcontext.opt_help.value then
- toolcontext.option_context.usage
- return
-end
# We need a model to collect stufs
var model = new Model