From 17f13785ce7eb2b19321380f365852469dd01b2e Mon Sep 17 00:00:00 2001 From: Zachary Flower Date: Sat, 10 Feb 2018 18:03:18 -0700 Subject: [PATCH] move alias registration into a separate register() method --- lib/vagrant/alias.rb | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/lib/vagrant/alias.rb b/lib/vagrant/alias.rb index 1d9ef2b8e..660ec001f 100644 --- a/lib/vagrant/alias.rb +++ b/lib/vagrant/alias.rb @@ -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