print_file("Contributing rules from", no_color)
end
end
+
+# CmdMain
+
+redef class CmdMains
+ redef fun execute(no_color) do
+ var mentity = self.mentity.as(not null).full_name
+ if no_color == null or not no_color then mentity = mentity.blue.bold
+ print_list("Mains in `{mentity}`:", results, no_color)
+ end
+end
+
+redef class CmdMainCompile
+ redef fun execute(no_color) do
+ var mentity = self.mentity.as(not null).full_name
+ if no_color == null or not no_color then mentity = mentity.blue.bold
+ var title = "Compiling `{mentity}`:"
+
+ if no_color == null or not no_color then
+ print title.bold
+ else
+ print title
+ end
+
+ print ""
+ var command = self.command
+ if command != null then print command
+ end
+end
+
+redef class CmdTesting
+ redef fun execute(no_color) do
+ var mentity = self.mentity.as(not null).full_name
+ if no_color == null or not no_color then mentity = mentity.blue.bold
+ var title = "Testing `{mentity}`:"
+
+ if no_color == null or not no_color then
+ print title.bold
+ else
+ print title
+ end
+
+ print ""
+ var command = self.command
+ if command != null then print command
+ end
+end
+
+redef class CmdManSynopsis
+ redef fun execute(no_color) do
+ var mentity = self.mentity.as(not null).full_name
+ if no_color == null or not no_color then mentity = mentity.blue.bold
+ var title = "Synopsis for `{mentity}`:"
+
+ if no_color == null or not no_color then
+ print title.bold
+ else
+ print title
+ end
+
+ print ""
+ var synopsis = self.synopsis
+ if synopsis != null then print synopsis
+ end
+end
+
+redef class CmdManOptions
+ redef fun execute(no_color) do
+ var mentity = self.mentity.as(not null).full_name
+ if no_color == null or not no_color then mentity = mentity.blue.bold
+ var title = "Options for `{mentity}`:"
+
+ if no_color == null or not no_color then
+ print title.bold
+ else
+ print title
+ end
+
+ print ""
+ var options = self.options.as(not null)
+ for opt, desc in options do
+ if no_color == null or not no_color then
+ print " * {opt.blue.bold}: {desc}"
+ else
+ print " * {opt}: {desc}"
+ end
+ end
+ end
+end
module test_term is test
import term
+intrude import commands::commands_main
import commands::test_commands_catalog
# Nitunit test suite specific to commands
var parser = new CommandParser(test_view, test_builder, test_catalog)
parser.execute("ini-license: test_prog", true)
end
+
+ # CmdMain
+
+ fun test_term_mains is test do
+ var parser = new CommandParser(test_view, test_builder, test_catalog)
+ parser.execute("mains: test_prog", true)
+ end
+
+ fun test_term_main_compile is test do
+ var parser = new CommandParser(test_view, test_builder, test_catalog)
+ parser.execute("main-compile: test_prog::test_prog", true)
+ end
+
+ fun test_term_man_synopsis is test do
+ var parser = new CommandParser(test_view, test_builder, test_catalog)
+ parser.execute("main-run: test_prog::test_prog", true)
+ end
+
+ fun test_term_man_options is test do
+ var parser = new CommandParser(test_view, test_builder, test_catalog)
+ parser.execute("main-opts: test_prog::test_prog", true)
+ end
+
+ fun test_term_testing is test do
+ var parser = new CommandParser(test_view, test_builder, test_catalog)
+ parser.execute("testing: test_prog", true)
+ end
end
redef class nitc::Location
# Avoid location diffs
redef fun to_s do return "test_location"
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