Commit 75f3d7a63759ce785c155875e3bec2243caeccf2
1 parent
5e7a172c
Exists in
master
and in
31 other branches
Improved menu.
Showing
1 changed file
with
13 additions
and
7 deletions
Show diff stats
Vagrantfile
@@ -9,22 +9,28 @@ | @@ -9,22 +9,28 @@ | ||
9 | default_box = "precise64" | 9 | default_box = "precise64" |
10 | if $stdin.isatty | 10 | if $stdin.isatty |
11 | if Dir.glob(File.join(File.dirname("__FILE__"), '.vagrant/**/id')).empty? | 11 | if Dir.glob(File.join(File.dirname("__FILE__"), '.vagrant/**/id')).empty? |
12 | + options = ["precise64", "trusty64", "chef/centos-7.0"] | ||
13 | + | ||
12 | puts "Bases boxes available locally:" | 14 | puts "Bases boxes available locally:" |
13 | puts '------------------------------' | 15 | puts '------------------------------' |
14 | system('vagrant', 'box', 'list') | 16 | system('vagrant', 'box', 'list') |
15 | puts | 17 | puts |
16 | puts 'Base boxes we can provide you:' | 18 | puts 'Base boxes we can provide you:' |
17 | puts '------------------------------' | 19 | puts '------------------------------' |
18 | - puts 'precise64 (virtualbox)' | ||
19 | - puts 'trusty64 (virtualbox)' | ||
20 | - puts 'chef/centos-7.0 (virtualbox)' | ||
21 | - puts | 20 | + options.each_with_index do |value, i| |
21 | + puts "[#{i + 1}] #{value}" | ||
22 | + end | ||
23 | + | ||
22 | print "Which box to use [#{default_box}]: " | 24 | print "Which box to use [#{default_box}]: " |
23 | choice = $stdin.gets.strip | 25 | choice = $stdin.gets.strip |
24 | - if !choice.empty? | ||
25 | - default_box = choice | 26 | + options.each_with_index do |option, i| |
27 | + if option == choice || choice.to_i == (i + 1) | ||
28 | + default_box = option | ||
29 | + puts default_box | ||
30 | + break | ||
31 | + end | ||
26 | end | 32 | end |
27 | - end | 33 | + end |
28 | end | 34 | end |
29 | 35 | ||
30 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! | 36 | # Vagrantfile API/syntax version. Don't touch unless you know what you're doing! |