Skip to content
Myr

gum.rb

This file

Path

examples/gum.rb

29 lines · 803 bytes · Ruby

Last changed by

Not known.

History of this file

Take it

1puts 'What is your name?'2name = `gum input --placeholder "Your name"`.chomp34puts "Hello #{name}!"56puts 'Pick your 2 favorite colors'78COLORS = {9  'Red' => '#FF0000',10  'Blue' => '#0000FF',11  'Green' => '#00FF00',12  'Yellow' => '#FFFF00',13  'Orange' => '#FFA500',14  'Purple' => '#800080',15  'Pink' => '#FF00FF'16}.freeze1718colors = `gum choose #{COLORS.keys.join(' ')} --limit 2`.chomp.split("\n")1920if colors.length == 221  first = `gum style --foreground '#{COLORS[colors[0]]}' '#{colors[0]}'`.chomp22  second = `gum style --foreground '#{COLORS[colors[1]]}' '#{colors[1]}'`.chomp23  puts "You chose #{first} and #{second}."24elsif colors.length == 125  first = `gum style --foreground '#{COLORS[colors[0]]}' '#{colors[0]}'`.chomp26  puts "You chose #{first}."27else28  puts "You didn't pick any colors!"29end