@@ -6,13 +6,23 @@ import std.regex;
66import std.stdio ;
77import std.typecons ;
88
9+ const USAGE = ` Usage: %s [options] FILE
10+ Process import dependencies as created by dmd with the --deps switch.
11+ Options:
12+ --dot Print the dependency graph in the DOT language
13+ -f, --filter REGEX Filter source files matching the regular expression
14+ -h, --help Display usage information, then exit
15+ -p, --packages Generalize to package dependencies
16+ -t, --target FILE Check against the PlantUML target dependencies` ;
17+
918alias Dependency = Tuple ! (string , " client" , string , " supplier" );
1019
1120int main (string [] args)
1221{
1322 import std.getopt : getopt;
1423
1524 bool dot = false ;
25+ bool help = false ;
1626 bool packages = false ;
1727 string filter;
1828 string target;
@@ -31,6 +41,14 @@ int main(string[] args)
3141 return 1 ;
3242 }
3343
44+ if (help)
45+ {
46+ import std.path : baseName;
47+
48+ writefln(USAGE , args[0 ].baseName);
49+ return 0 ;
50+ }
51+
3452 File file = (args.length > 1 ) ? File (args[1 ]) : stdin;
3553 auto pattern = regex(filter);
3654 Dependency[] actualDependencies = moduleDependencies(file, pattern);
@@ -144,7 +162,7 @@ void write(in Dependency[] dependencies)
144162 writeln(" digraph Dependencies {" );
145163 writeln(" node [shape=box];" );
146164 foreach (element; dependencies.elements)
147- writeln(' "' , element,' "' );
165+ writeln(' "' , element, ' "' );
148166 foreach (dependency; dependencies)
149167 writeln(' "' , dependency.client, ' "' , " -> " , ' "' , dependency.supplier, ' "' );
150168 writeln(" }" );
0 commit comments