changeset 427:e2bbc6406a14

Added a new option '-m' to the igraph command.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Mon, 01 Oct 2007 18:49:26 +0200
parents 3f7790d3f9d6
children 3751db263679
files trunk/src/cmd/ImportGraph.d trunk/src/lang_en.d trunk/src/main.d
diffstat 3 files changed, 27 insertions(+), 17 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/cmd/ImportGraph.d	Mon Oct 01 15:38:30 2007 +0200
+++ b/trunk/src/cmd/ImportGraph.d	Mon Oct 01 18:49:26 2007 +0200
@@ -22,13 +22,14 @@
 {
   None,
   IncludeUnlocatableModules = 1,
-  HighlightCyclicEdges      = 1<<1,
-  HighlightCyclicVertices   = 1<<2,
-  PrintDot                  = 1<<3,
-  PrintPaths                = 1<<4,
-  PrintList                 = 1<<5,
-  GroupByPackageNames       = 1<<6,
-  GroupByFullPackageName    = 1<<7,
+  PrintDot                  = 1<<1,
+  HighlightCyclicEdges      = 1<<2,
+  HighlightCyclicVertices   = 1<<3,
+  GroupByPackageNames       = 1<<4,
+  GroupByFullPackageName    = 1<<5,
+  PrintPaths                = 1<<6,
+  PrintList                 = 1<<7,
+  MarkCyclicModules         = 1<<8,
 }
 
 string findModulePath(string moduleFQN, string[] importPaths)
@@ -162,11 +163,17 @@
   // Finished loading modules.
 
 
-  if (options & IGraphOption.PrintPaths)
-    printPaths(loadedModulesList, levels+1, "");
-  else if (options & IGraphOption.PrintList)
-    printList(loadedModulesList, levels+1, "");
-  else if (options & IGraphOption.PrintDot)
+  if (options & (IGraphOption.PrintList | IGraphOption.PrintPaths))
+  {
+    if (options & IGraphOption.MarkCyclicModules)
+      analyzeGraph(loadedModulesList, edges.dup);
+
+    if (options & IGraphOption.PrintPaths)
+      printPaths(loadedModulesList, levels+1, "");
+    else
+      printList(loadedModulesList, levels+1, "");
+  }
+  else 
     printDot(loadedModulesList, edges, options);
 }
 
@@ -176,7 +183,7 @@
     return;
   foreach (vertex; vertices)
   {
-    Stdout(indent)(vertex.filePath).newline;
+    Stdout(indent)((vertex.isCyclic?"*":"")~vertex.filePath).newline;
     if (vertex.outgoing.length)
       printPaths(vertex.outgoing, level-1, indent~"  ");
   }
@@ -188,7 +195,7 @@
     return;
   foreach (vertex; vertices)
   {
-    Stdout(indent)(vertex.getFQN()).newline;
+    Stdout(indent)((vertex.isCyclic?"*":"")~vertex.getFQN()).newline;
     if (vertex.outgoing.length)
       printList(vertex.outgoing, level-1, indent~"  ");
   }
--- a/trunk/src/lang_en.d	Mon Oct 01 15:38:30 2007 +0200
+++ b/trunk/src/lang_en.d	Mon Oct 01 18:49:26 2007 +0200
@@ -93,16 +93,17 @@
 
 Format:
   --dot            : generate a dot document
+  Further options for --dot:
   -gbp             : Group modules by package names
   -gbf             : Group modules by full package name
   -hle             : highlight cyclic edges in the graph
   -hlv             : highlight modules in cyclic relationship
 
   --paths          : print a list of paths to the modules imported by file.d
+  --list           : print a list of the module names imported by file.d
+  Options common to --paths and --list:
   -lN              : print N levels.
-
-  --list           : print a list of the module names imported by file.d
-  -lN              : print N levels.
+  -m               : mark modules in cyclic relationships with a star.
 
 Options:
   -Ipath           : add 'path' to the list of import paths where modules are
--- a/trunk/src/main.d	Mon Oct 01 15:38:30 2007 +0200
+++ b/trunk/src/main.d	Mon Oct 01 18:49:26 2007 +0200
@@ -81,6 +81,8 @@
           options |= IGraphOption.GroupByPackageNames; break;
         case "-gbf":
           options |= IGraphOption.GroupByFullPackageName; break;
+        case "-m":
+          options |= IGraphOption.MarkCyclicModules; break;
         default:
           filePath = arg;
         }