bin/u-menu in u-menu-0.4.0 vs bin/u-menu in u-menu-0.6.0

- old
+ new

@@ -1,40 +1,25 @@ #!/usr/bin/env ruby -require 'pastel' +require_relative '../lib/u-menu' + require 'tty-prompt' -require 'yaml' +config = Micro::Menu.configurations.load -paths = [ - File.expand_path("#{Dir.home}/.umenurc.yml", __dir__), - File.expand_path("#{Dir.home}/.umenu/umenurc.yml", __dir__), -] +colors = Micro::Menu.colors +prompt = TTY::Prompt.new(prefix: colors.magenta("\uea85 \u00b5menu "), interrupt: :signal) -config_path = paths.first { |path| File.exist? path } -config = YAML.load_file(config_path, symbolize_names: true) +icons = Micro::Menu.icons.all -pastel = Pastel.new -prompt = TTY::Prompt.new(prefix: pastel.magenta("\uea85 \u00b5menu "), interrupt: :signal) - -icons = { - 'run' => "\ueb9e", - 'terminal' => "\uea85", - 'github' => "\uea84", - 'chart' => "\ue760", - 'jira' => "\ue75c", - 'settings' => "\ue615", - 'link' => "\ueb15" -} - thanks = [ - pastel.green('Great job! o/'), - pastel.green('See you later! =)'), - pastel.green('Baby bye bye bye...'), - "Bring me #{pastel.green('a cookie')} when you come back!?", - "Have a nice #{pastel.cyan('day')}! =)", - "See you later #{pastel.green('olligator')}! =)" + colors.green('Great job! o/'), + colors.green('See you later! =)'), + colors.green('Baby bye bye bye...'), + "Bring me #{colors.green('a cookie')} when you come back!?", + "Have a nice #{colors.cyan('day')}! =)", + "See you later #{colors.green('olligator')}! =)" ] trap('INT') do puts "\n\n#{thanks.sample}" exit(0) @@ -45,11 +30,11 @@ options << { name: '{{settings}} Edit Settings', type: 'edit', value: 'settings', - execute: config_path + execute: config[:_path] } options = options.sort { |a, b| a[:name] <=> b[:name] } options.each do |option| if option[:name].match(/\{\{(?<icon_name>.*)\}\}/) @@ -67,17 +52,17 @@ case action[:type] when 'command' system action[:execute] when 'link' - puts "#{pastel.bold('Sure... opening link')} '#{pastel.cyan(action[:execute])}'" + puts "#{colors.bold('Sure... opening link')} '#{colors.cyan(action[:execute])}'" system "open #{action[:execute]} &" when 'edit' - puts "#{pastel.bold('Sure... opening file')} '#{pastel.cyan(action[:execute])}'" + puts "#{colors.bold('Sure... opening file')} '#{colors.cyan(action[:execute])}'" system "#{config[:settings][:editor]} #{action[:execute]}" end exit(0) rescue StandardError => e - puts "#{pastel.red('[error]')} #{e}" + puts "#{colors.red('[error]')} #{e}" exit(1) end