Sha256: 9c2e3842bd3fca0ce68a32c794a4603ece54ede22f21149dac2fd2bb17387269
Contents?: true
Size: 1.75 KB
Versions: 9
Compression:
Stored size: 1.75 KB
Contents
# frozen_string_literal: true require_relative '../models/color_theme' require_relative '../services/stderr_redirector_service' require_relative '../views/shared/error' require_relative 'color_themable' module Dsu module Support module CommandHookable class << self def included(base) base.extend(ColorThemable) base.extend(ClassMethods) end end module ClassMethods def start(args = ARGV, options = {}) display_dsu_header unless suspend_header?(args, options) stderror = Services::StderrRedirectorService.call do super end display_errors_if(stderror) display_dsu_footer end def display_dsu_header puts apply_theme("Dsu v#{Dsu::VERSION}", theme_color: color_theme.dsu_header) puts end def display_dsu_footer puts apply_theme('_' * 35, theme_color: color_theme.dsu_footer) # TODO: I18n. footer = apply_theme("Theme: #{color_theme.theme_name}", theme_color: color_theme.dsu_footer) puts footer end private def suspend_header?(args, _options) return false unless args.count > 1 # TODO: I18n? true if args[0] == 'theme' && %w[use delete].include?(args[1]) end def display_errors_if(stderror_string) stderror_string = stderror_string.strip return unless stderror_string.present? errors = stderror_string.split("\n").map(&:strip) Views::Shared::Error.new(messages: errors, options: options.merge({ ordered_list: false })).render end def color_theme Models::ColorTheme.current_or_default end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems