From 75f3d7a63759ce785c155875e3bec2243caeccf2 Mon Sep 17 00:00:00 2001 From: rodrigosiqueira Date: Tue, 21 Jul 2015 15:37:49 -0300 Subject: [PATCH] Improved menu. --- Vagrantfile | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index 97f8a82..5dca5ab 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -9,22 +9,28 @@ default_box = "precise64" if $stdin.isatty if Dir.glob(File.join(File.dirname("__FILE__"), '.vagrant/**/id')).empty? + options = ["precise64", "trusty64", "chef/centos-7.0"] + puts "Bases boxes available locally:" puts '------------------------------' system('vagrant', 'box', 'list') puts puts 'Base boxes we can provide you:' puts '------------------------------' - puts 'precise64 (virtualbox)' - puts 'trusty64 (virtualbox)' - puts 'chef/centos-7.0 (virtualbox)' - puts + options.each_with_index do |value, i| + puts "[#{i + 1}] #{value}" + end + print "Which box to use [#{default_box}]: " choice = $stdin.gets.strip - if !choice.empty? - default_box = choice + options.each_with_index do |option, i| + if option == choice || choice.to_i == (i + 1) + default_box = option + puts default_box + break + end end - end + end end # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! -- libgit2 0.21.2