Add a general purpose ui "messager" / "logger" Action

This commit is contained in:
Fabio Rehm 2013-04-12 22:08:37 -03:00
parent b5cc9c0ac3
commit 3a458df621
2 changed files with 23 additions and 0 deletions

View file

@ -11,6 +11,7 @@ require 'vagrant-lxc/action/forced_halt'
require 'vagrant-lxc/action/forward_ports'
require 'vagrant-lxc/action/handle_box_metadata'
require 'vagrant-lxc/action/is_running'
require 'vagrant-lxc/action/message'
require 'vagrant-lxc/action/setup_package_files'
require 'vagrant-lxc/action/share_folders'

View file

@ -0,0 +1,22 @@
module Vagrant
module LXC
module Action
class Message
def initialize(app, env, msg_key, type = :info)
@app = app
@msg_key = msg_key
@type = type
end
def call(env)
machine = env[:machine]
message = I18n.t("vagrant_lxc.messages.#{@msg_key}", name: machine.name)
env[:ui].send @type, message
@app.call env
end
end
end
end
end