vendored/puppet/lib/puppet/module_tool/errors/uninstaller.rb in bolt-0.8.0 vs vendored/puppet/lib/puppet/module_tool/errors/uninstaller.rb in bolt-0.9.0
- old
+ new
@@ -9,17 +9,26 @@
@version = options[:version_range]
super _("Could not uninstall '%{module_name}'; no installed version matches") % { module_name: @module_name }
end
def multiline
- message = []
- message << _("Could not uninstall module '%{module_name}' (%{version})") % { module_name: @module_name, version: v(@version) }
- message << _(" No installed version of '%{module_name}' matches (%{version})") % { module_name: @module_name, version: v(@version) }
- message += @modules.map do |mod|
+ module_versions_list = @modules.map do |mod|
_(" '%{module_name}' (%{version}) is installed in %{path}") % { module_name: mod[:name], version: v(mod[:version]), path: mod[:path] }
+ end.join("\n")
+
+ if module_versions_list.empty?
+ _(<<-MSG).chomp % { module_name: @module_name, version: v(@version)}
+Could not uninstall module '%{module_name}' (%{version})
+ No installed version of '%{module_name}' matches (%{version})
+ MSG
+ else
+ _(<<-MSG).chomp % { module_name: @module_name, version: v(@version), module_versions_list: module_versions_list }
+Could not uninstall module '%{module_name}' (%{version})
+ No installed version of '%{module_name}' matches (%{version})
+%{module_versions_list}
+ MSG
end
- message.join("\n")
end
end
class ModuleIsRequiredError < UninstallError
def initialize(options)
@@ -30,20 +39,34 @@
super _("Could not uninstall '%{module_name}'; installed modules still depend upon it") % { module_name: @module_name }
end
def multiline
- message = []
+
+ module_requirements_list = @required_by.map do |mod|
+ msg_variables = { module_name: mod['name'], version: v(mod['version']), module_dependency: @module_name,
+ dependency_version: v(mod['version_requirement']) }
+ _(" '%{module_name}' (%{version}) requires '%{module_dependency}' (%{dependency_version})") % msg_variables
+ end.join("\n")
+
if @requested_version
- message << _("Could not uninstall module '%{module_name}' (v%{requested_version})") % { module_name: @module_name, requested_version: @requested_version }
+ msg_variables = { module_name: @module_name, requested_version: @requested_version, version: v(@installed_version),
+ module_requirements_list: module_requirements_list }
+ #TRANSLATORS `puppet module uninstall --force` is a command line option that should not be translated
+ _(<<-EOF).chomp % msg_variables
+Could not uninstall module '%{module_name}' (v%{requested_version})
+ Other installed modules have dependencies on '%{module_name}' (%{version})
+%{module_requirements_list}
+ Use `puppet module uninstall --force` to uninstall this module anyway
+ EOF
else
- message << _("Could not uninstall module '%{module_name}'") % { module_name: @module_name }
+ #TRANSLATORS `puppet module uninstall --force` is a command line option that should not be translated
+ _(<<-EOF) % { module_name: @module_name, version: v(@installed_version), module_requirements_list: module_requirements_list }
+Could not uninstall module '%{module_name}'
+ Other installed modules have dependencies on '%{module_name}' (%{version})
+%{module_requirements_list}
+ Use `puppet module uninstall --force` to uninstall this module anyway
+ EOF
end
- message << _(" Other installed modules have dependencies on '%{module_name}' (%{version})") % { module_name: @module_name, version: v(@installed_version) }
- message += @required_by.map do |mod|
- _(" '%{module_name}' (%{version}) requires '%{module_dep}' (%{dep_version})") % { module_name: mod['name'], version: v(mod['version']), module_dep: @module_name, dep_version: v(mod['version_requirement']) }
- end
- message << _(" Use `puppet module uninstall --force` to uninstall this module anyway")
- message.join("\n")
end
end
end