Add a general purpose ui "messager" / "logger" Action
This commit is contained in:
parent
b5cc9c0ac3
commit
3a458df621
2 changed files with 23 additions and 0 deletions
|
@ -11,6 +11,7 @@ require 'vagrant-lxc/action/forced_halt'
|
||||||
require 'vagrant-lxc/action/forward_ports'
|
require 'vagrant-lxc/action/forward_ports'
|
||||||
require 'vagrant-lxc/action/handle_box_metadata'
|
require 'vagrant-lxc/action/handle_box_metadata'
|
||||||
require 'vagrant-lxc/action/is_running'
|
require 'vagrant-lxc/action/is_running'
|
||||||
|
require 'vagrant-lxc/action/message'
|
||||||
require 'vagrant-lxc/action/setup_package_files'
|
require 'vagrant-lxc/action/setup_package_files'
|
||||||
require 'vagrant-lxc/action/share_folders'
|
require 'vagrant-lxc/action/share_folders'
|
||||||
|
|
||||||
|
|
22
lib/vagrant-lxc/action/message.rb
Normal file
22
lib/vagrant-lxc/action/message.rb
Normal 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
|
Loading…
Reference in a new issue