Module: Vbuilder::Helper::Cli

Defined in:
lib/helper.rb

Class Method Summary collapse

Class Method Details

.start_cli(attributes) ⇒ Object

this method gets kicked off when the user chooses to interactively create it



45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/helper.rb', line 45

def self.start_cli(attributes)
    cli = HighLine.new
    attributes.each do |key, value|
        if key != "meta"
            case attributes[key]
                when Array
                    attributes[key] = cli.ask("#{key} - (comma sep list) :", lambda { |val|val.split(/,\s*/)  })
                when String
                    attributes[key] = cli.ask("#{key}: ")
                when Fixnum
                    attributes[key] = cli.ask("#{key}: ", Integer)
                when Float
                    attributes[key] = cli.ask("#{key}: ", Float)
                when TrueClass
                    attributes[key] = cli.ask("#{key} - (true or false): ")
                when FalseClass
                    attributes[key] = cli.ask("#{key} - (true or false): ")
                else
                    puts attributes[key].class
            end
        end
    end

    attributes
end