Sha256: 69fb61576030e8ff66123dc29f08aa60cec3d9df6b9a1f2b8ccd54c24ef20619

Contents?: true

Size: 864 Bytes

Versions: 2

Compression:

Stored size: 864 Bytes

Contents

require_relative 'make_menu/color_string'
require_relative 'make_menu/menu'
require_relative 'make_menu/status_panel'

require 'tty-screen'

module MakeMenu
  String.include MakeMenu::ColorString

  def self.run
    # Allows CTRL+C to return to the menu instead of exiting the script
    trap('SIGINT') { throw StandardError }

    makefile = ENV.fetch('MAKEFILE', './Makefile')

    if (menu_name = ENV.fetch('MENU', nil))
      require "./#{menu_name.downcase}_menu.rb"
      Object.const_get("#{menu_name.capitalize}Menu").new(makefile).run
    else
      MakeMenu::Menu.new(makefile).run
    end
  end

  def self.status
    if (menu_name = ENV.fetch('MENU', nil))
      require "./#{menu_name.downcase}_status_panel.rb"
      Object.const_get("#{menu_name.capitalize}StatusPanel").new.display
    else
      MakeMenu::StatusPanel.new.display
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
make_menu-0.0.2 lib/make_menu.rb
make_menu-0.0.1 lib/make_menu.rb