lib/make_menu/menu.rb in make_menu-0.0.5 vs lib/make_menu/menu.rb in make_menu-0.1.0

- old
+ new

@@ -10,16 +10,14 @@ class Menu # @param [String] makefile Makefile name def initialize(makefile) @groups = [] @items = [] - @status_present = false build makefile end attr_reader :groups, :items - attr_accessor :status_present # Display menu and prompt for command # rubocop:disable Metrics/MethodLength def run running = true @@ -46,11 +44,10 @@ # rubocop:enable Metrics/MethodLength # Display the company logo and the status bar (if set) def display_header puts formatted_logo if logo - puts `make status` if status_present end private # Build a menu from the specified Makefile @@ -74,16 +71,10 @@ description = line.split('##').last.strip # Target 'menu' should not appear next if target == 'menu' - # Target 'status' should not appear, but is run automatically when the menu is rendered - if target == 'status' - self.status_present = true - next - end - unless current_group current_group = MenuItemGroup.new('Commands'.color(group_title_color)) groups << current_group end @@ -104,10 +95,17 @@ puts exit 1 end end + rescue Errno::ENOENT => _e + puts + puts 'No Makefile!'.red.bold + puts + puts "File '#{makefile}' could not be found.".yellow + puts + exit 1 end # rubocop:enable Metrics/MethodLength # Execute the selected menu item @@ -160,17 +158,15 @@ Object.const_get("#{self.class.name}::LOGO") end protected - # Override the following methods to customise the menu display - # @return [Symbol,Array[Symbol]] Color for group title def group_title_color %i[yellow bold] end - # Clean screen before and after each command + # Clear screen before and after each command def clear_screen? true end end end