lib/terraspace/all/grapher.rb in terraspace-0.5.8 vs lib/terraspace/all/grapher.rb in terraspace-0.5.9
- old
+ new
@@ -107,23 +107,40 @@
name if system("type #{name} > /dev/null 2>&1") # c9 = cloud9, open = macosx
end
# Check if Graphiz is installed and prints a user friendly message if it is not installed.
def check_graphviz!
+ return if @options[:format] == 'text'
+
installed = system("type dot > /dev/null 2>&1") # dot is a command that is part of the graphviz package
return if installed
logger.error "ERROR: It appears that the Graphviz is not installed. Please install it to use the graph command.".color(:red)
- if RUBY_PLATFORM =~ /darwin/
- logger.error "You can install Graphviz with homebrew:"
- logger.error " brew install graphviz"
- end
+ install_instructions
logger.info <<~EOL
Also consider:
terraspace all graph --format text
Which will print out the graph in text form.
EOL
exit 1
+ end
+
+ def install_instructions
+ installer = if RUBY_PLATFORM =~ /darwin/
+ "brew"
+ elsif system("type yum > /dev/null 2>&1")
+ "yum"
+ elsif system("type apt-get > /dev/null 2>&1")
+ "apt-get"
+ end
+
+ return unless installer
+ logger.error <<~EOL
+ You can install Graphviz with:
+
+ #{installer} install graphviz
+
+ EOL
end
end
end