import commands::commands_usage
import commands::commands_catalog
import commands::commands_ini
+import commands::commands_main
import templates::templates_json
import catalog::catalog_json
return obj
end
end
+
+# CmdMain
+
+redef class CmdMains
+ redef fun to_json do
+ var obj = new JsonObject
+ obj["results"] = results
+ return obj
+ end
+end
+
+redef class CmdMainCompile
+ redef fun to_json do
+ var obj = new JsonObject
+ obj["command"] = command
+ return obj
+ end
+end
+
+redef class CmdTesting
+ redef fun to_json do
+ var obj = new JsonObject
+ obj["command"] = command
+ return obj
+ end
+end
+
+redef class CmdManSynopsis
+ redef fun to_json do
+ var obj = new JsonObject
+ obj["synopsis"] = synopsis
+ return obj
+ end
+end
+
+redef class CmdManOptions
+ redef fun to_json do
+ var obj = new JsonObject
+ obj["options"] = options
+ return obj
+ end
+end
module test_commands_json is test
import test_commands
+intrude import doc::commands::commands_main
import doc::commands::commands_json
class TestCommandsJson
cmd.file = cmd.file.as(not null).basename # for testing path
print_json cmd.to_json
end
+
+ # CmdMain
+
+ fun test_cmd_mains is test do
+ var cmd = new CmdMains(test_view, mentity_name = "test_prog")
+ cmd.init_command
+ print_json cmd.to_json
+ end
+
+ fun test_cmd_main_compile is test do
+ var cmd = new CmdMainCompile(test_view, mentity_name = "test_prog::test_prog")
+ cmd.init_command
+ print_json cmd.to_json
+ end
+
+ fun test_cmd_testing is test do
+ var cmd = new CmdTesting(test_view, mentity_name = "test_prog")
+ cmd.init_command
+ print_json cmd.to_json
+ end
+
+ fun test_cmd_man_synopsis is test do
+ var cmd = new CmdManSynopsis(test_view, mentity_name = "test_prog")
+ cmd.init_command
+ print_json cmd.to_json
+ end
+
+ fun test_cmd_man_options is test do
+ var cmd = new CmdManOptions(test_view, mentity_name = "test_prog")
+ cmd.init_command
+ print_json cmd.to_json
+ end
end
redef class nitc::Location
end
end
end
+
+# Avoid path diff
+redef class CmdMainCompile
+ redef fun test_path(file) do
+ if file == null then return null
+ return file.filename.basename
+ end
+end
+
+# Avoid path diff
+redef class CmdTesting
+ redef fun test_path(mentity) do
+ var file = mentity.location.file
+ if file == null then return null
+ return file.filename.basename
+ end
+end
--- /dev/null
+{
+ "command": "nitc test_prog.nit"
+}
--- /dev/null
+{
+ "results": [{
+ "name": "test_prog",
+ "synopsis": "A test program with a fake model to check model tools.",
+ "namespace": [{
+ "name": "test_prog",
+ "synopsis": "Test program for model tools."
+ }, "::", {
+ "name": "test_prog",
+ "synopsis": "A test program with a fake model to check model tools."
+ }],
+ "class_name": "MModule",
+ "full_name": "test_prog::test_prog",
+ "visibility": "public",
+ "html_synopsis": "<span class=\"synopsys nitdoc\">A test program with a fake model to check model tools.</span>",
+ "modifiers": ["module"]
+ }]
+}
--- /dev/null
+{
+ "options": {
+ "--opt1": "Option 1.",
+ "--opt2": "Option 2."
+ }
+}
--- /dev/null
+{
+ "synopsis": "test_prog [*options*] ARGS..."
+}
--- /dev/null
+{
+ "command": "nitunit tests"
+}