move alias registration into a separate register() method
This commit is contained in:
parent
bbb3cdaa9a
commit
17f13785ce
|
@ -15,22 +15,28 @@ module Vagrant
|
|||
# separate keyword-command pairs
|
||||
keyword, command = line.split("=").collect(&:strip)
|
||||
|
||||
@aliases.register(keyword.to_sym) do
|
||||
lambda do |args|
|
||||
# directly execute shell commands
|
||||
if command.start_with?("!")
|
||||
return exec "#{command[1..-1]} #{args.join(" ")}".strip
|
||||
end
|
||||
|
||||
return CLI.new(command.split.concat(args), env).execute
|
||||
end
|
||||
end
|
||||
register(keyword, command)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# This returns all the registered alias commands.
|
||||
def commands
|
||||
@aliases
|
||||
end
|
||||
|
||||
# This registers an alias.
|
||||
def register(keyword, command)
|
||||
@aliases.register(keyword.to_sym) do
|
||||
lambda do |args|
|
||||
# directly execute shell commands
|
||||
if command.start_with?("!")
|
||||
return exec "#{command[1..-1]} #{args.join(" ")}".strip
|
||||
end
|
||||
|
||||
return CLI.new(command.split.concat(args), env).execute
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue