16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/archsight/cli.rb', line 16
def graph(path)
path = File.expand_path(path)
unless File.directory?(path)
warn "Error: not a directory: #{path}"
exit 1
end
load_handlers
handler_classes = resolve_handler(path, options[:language])
if handler_classes.empty?
warn "Could not detect language for #{path} — use --language go|python|java"
exit 1
end
require "archsight/import/progress"
stub = Struct.new(:name, :annotations, :path_ref).new("module-graph", {}, nil)
any_output = false
handler_classes.each do |handler_class|
progress = Archsight::Import::Progress.new(output: $stderr)
handler = handler_class.new(stub, database: nil, resources_dir: Dir.tmpdir,
progress: progress)
dot = handler.dot_graph(path: path, ranksep: options[:ranksep],
nodesep: options[:nodesep])
next unless dot
puts "# #{handler_class.language_name} modules" if handler_classes.size > 1
puts dot
any_output = true
end
return if any_output
warn "No modules found in #{path}"
exit 1
end
|