nitls: add -M option do list dependencies
authorJean Privat <jean@pryen.org>
Wed, 19 Mar 2014 13:46:47 +0000 (09:46 -0400)
committerJean Privat <jean@pryen.org>
Wed, 19 Mar 2014 13:46:47 +0000 (09:46 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/nitls.nit
tests/sav/nitls.res

index ac2e549..6e266d9 100644 (file)
@@ -29,12 +29,13 @@ var opt_recursive = new OptionBool("Process directories recussively", "-r", "--r
 var opt_tree = new OptionBool("List source files in their groups and projects", "-t", "--tree")
 var opt_source = new OptionBool("List source files", "-s", "--source")
 var opt_project = new OptionBool("List projects paths (default)", "-p", "--project")
+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)
+tc.option_context.add_option(opt_keep, opt_recursive, opt_tree, opt_source, opt_project, opt_depends)
 
 tc.process_options
 
-var sum = opt_tree.value.to_i + opt_source.value.to_i + opt_project.value.to_i
+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"
@@ -42,6 +43,18 @@ if sum > 1 or tc.option_context.rest.is_empty or tc.opt_help.value then
        exit 0
 end
 
+if opt_depends.value then
+       if opt_recursive.value then
+               print "-M incompatible with -r"
+               exit 1
+       end
+
+       mb.parse(tc.option_context.rest)
+       for x in model.mmodules do
+               print x.location.file.filename
+       end
+end
+
 if sum == 0 then opt_project.value = true
 
 var files
index 303e63d..06aa3b2 100644 (file)
@@ -17,3 +17,4 @@ List Nit source files
   -t, --tree              List source files in their groups and projects
   -s, --source            List source files
   -p, --project           List projects paths (default)
+  -M, --depends           List dependencies of given modules