doc/commands: term handles `commands_ini`
authorAlexandre Terrasa <alexandre@moz-code.org>
Wed, 2 May 2018 23:40:42 +0000 (19:40 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Tue, 8 May 2018 19:48:00 +0000 (15:48 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

src/doc/term/term.nit
src/doc/term/tests/test_term.nit
src/doc/term/tests/test_term.sav/test_term_ini_clone.res [new file with mode: 0644]
src/doc/term/tests/test_term.sav/test_term_ini_contributors.res [new file with mode: 0644]
src/doc/term/tests/test_term.sav/test_term_ini_desc.res [new file with mode: 0644]
src/doc/term/tests/test_term.sav/test_term_ini_git.res [new file with mode: 0644]
src/doc/term/tests/test_term.sav/test_term_ini_issues.res [new file with mode: 0644]
src/doc/term/tests/test_term.sav/test_term_ini_license.res [new file with mode: 0644]
src/doc/term/tests/test_term.sav/test_term_ini_maintainer.res [new file with mode: 0644]

index 200d93f..b88a340 100644 (file)
@@ -347,3 +347,108 @@ redef class CmdCatalogContributing
                print_list("Packages contributed by `{name}`:", results, no_color)
        end
 end
+
+# CmdIni
+
+redef class CmdIni
+       # Print ini data
+       fun print_ini(title: String, data: nullable String, no_color: nullable Bool) do
+               if data == null then return
+               if no_color == null or not no_color then
+                       print title.bold
+               else
+                       print title
+               end
+               print ""
+               print data
+       end
+end
+
+redef class CmdIniDescription
+       redef fun execute(no_color) do
+               var title = "Description from ini file:"
+               print_ini(title, desc, no_color)
+       end
+end
+
+redef class CmdIniGitUrl
+       redef fun execute(no_color) do
+               var title = "Git URL from ini file:"
+               print_ini(title, url, no_color)
+       end
+end
+
+redef class CmdIniCloneCommand
+       redef fun execute(no_color) do
+               var title = "Git clone command from ini file:"
+               print_ini(title, command, no_color)
+       end
+end
+
+redef class CmdIniIssuesUrl
+       redef fun execute(no_color) do
+               var title = "Issues URL from ini file:"
+               print_ini(title, url, no_color)
+       end
+end
+
+redef class CmdIniMaintainer
+       redef fun execute(no_color) do
+               var title = "Maintainer from ini file:"
+               print_ini(title, maintainer, no_color)
+       end
+end
+
+redef class CmdIniContributors
+       redef fun execute(no_color) do
+               var contributors = self.contributors
+               if contributors == null then return
+               var title = "Contributors list from ini file:"
+               if no_color == null or not no_color then
+                       print title.bold
+               else
+                       print title
+               end
+               print ""
+               for contributor in contributors do
+                       print " * {contributor}"
+               end
+       end
+end
+
+redef class CmdIniLicense
+       redef fun execute(no_color) do
+               var title = "License from ini file:"
+               print_ini(title, license, no_color)
+       end
+end
+
+redef class CmdEntityFile
+
+       # Print file
+       fun print_file(title: String, no_color: nullable Bool) do
+               var file = self.file
+               if file == null then return
+               title = "{title} `{file}`:"
+               if no_color == null or not no_color then
+                       print title.bold
+               else
+                       print title
+               end
+               print ""
+               print file.to_path.read_all
+               print ""
+       end
+end
+
+redef class CmdLicenseFile
+       redef fun execute(no_color) do
+               print_file("License from", no_color)
+       end
+end
+
+redef class CmdContribFile
+       redef fun execute(no_color) do
+               print_file("Contributing rules from", no_color)
+       end
+end
index 08530da..e0d0e62 100644 (file)
@@ -194,6 +194,43 @@ class TestTerm
                var parser = new CommandParser(test_view, test_builder, test_catalog)
                parser.execute("contrib: Alexandre Terrasa", true)
        end
+
+       # CmdIni
+
+       fun test_term_ini_desc is test do
+               var parser = new CommandParser(test_view, test_builder, test_catalog)
+               parser.execute("ini-desc: test_prog", true)
+       end
+
+       fun test_term_ini_git is test do
+               var parser = new CommandParser(test_view, test_builder, test_catalog)
+               parser.execute("ini-git: test_prog", true)
+       end
+
+       fun test_term_ini_clone is test do
+               var parser = new CommandParser(test_view, test_builder, test_catalog)
+               parser.execute("git-clone: test_prog", true)
+       end
+
+       fun test_term_ini_issues is test do
+               var parser = new CommandParser(test_view, test_builder, test_catalog)
+               parser.execute("ini-issues: test_prog", true)
+       end
+
+       fun test_term_ini_maintainer is test do
+               var parser = new CommandParser(test_view, test_builder, test_catalog)
+               parser.execute("ini-maintainer: test_prog", true)
+       end
+
+       fun test_term_ini_contributors is test do
+               var parser = new CommandParser(test_view, test_builder, test_catalog)
+               parser.execute("ini-contributors: test_prog", true)
+       end
+
+       fun test_term_ini_license is test do
+               var parser = new CommandParser(test_view, test_builder, test_catalog)
+               parser.execute("ini-license: test_prog", true)
+       end
 end
 
 redef class nitc::Location
diff --git a/src/doc/term/tests/test_term.sav/test_term_ini_clone.res b/src/doc/term/tests/test_term.sav/test_term_ini_clone.res
new file mode 100644 (file)
index 0000000..9fd2554
--- /dev/null
@@ -0,0 +1,3 @@
+Git clone command from ini file:
+
+git clone https://github.com/nitlang/nit.git
diff --git a/src/doc/term/tests/test_term.sav/test_term_ini_contributors.res b/src/doc/term/tests/test_term.sav/test_term_ini_contributors.res
new file mode 100644 (file)
index 0000000..7a4a3e8
--- /dev/null
@@ -0,0 +1,5 @@
+Contributors list from ini file:
+
+ * Riri <riri@example.com>
+ * Fifi (http://www.example.com/~fifi)
+ * Loulou
diff --git a/src/doc/term/tests/test_term.sav/test_term_ini_desc.res b/src/doc/term/tests/test_term.sav/test_term_ini_desc.res
new file mode 100644 (file)
index 0000000..2fbbad6
--- /dev/null
@@ -0,0 +1,3 @@
+Description from ini file:
+
+Dummy program used for testing Nit tools
diff --git a/src/doc/term/tests/test_term.sav/test_term_ini_git.res b/src/doc/term/tests/test_term.sav/test_term_ini_git.res
new file mode 100644 (file)
index 0000000..998e12e
--- /dev/null
@@ -0,0 +1,3 @@
+Git URL from ini file:
+
+https://github.com/nitlang/nit.git
diff --git a/src/doc/term/tests/test_term.sav/test_term_ini_issues.res b/src/doc/term/tests/test_term.sav/test_term_ini_issues.res
new file mode 100644 (file)
index 0000000..6c44924
--- /dev/null
@@ -0,0 +1,3 @@
+Issues URL from ini file:
+
+https://github.com/nitlang/nit/issues
diff --git a/src/doc/term/tests/test_term.sav/test_term_ini_license.res b/src/doc/term/tests/test_term.sav/test_term_ini_license.res
new file mode 100644 (file)
index 0000000..ebd3e21
--- /dev/null
@@ -0,0 +1,3 @@
+License from ini file:
+
+Apache-2.0
diff --git a/src/doc/term/tests/test_term.sav/test_term_ini_maintainer.res b/src/doc/term/tests/test_term.sav/test_term_ini_maintainer.res
new file mode 100644 (file)
index 0000000..193379f
--- /dev/null
@@ -0,0 +1,3 @@
+Maintainer from ini file:
+
+John Doe <jdoe@example.com> (http://www.example.com/~jdoe), Spider-Man