Sha256: 763c8c5cf000d0bc429f9b24b35a7c5da65bef654eb26b3bf1f7fa713d9f58be
Contents?: true
Size: 1.33 KB
Versions: 5
Compression:
Stored size: 1.33 KB
Contents
require_relative 'command_base' require_relative 'color' require_relative '../repository' require_relative '../search' class I18nFlow::CLI class SearchCommand < CommandBase require_relative 'search_command/default_renderer' require_relative 'search_command/oneline_renderer' DEFAULT_FORMAT = 'default' def invoke! unless pattern exit_with_message(1, 'usage: i18n_flow search PATTERN') end search.search! case output_format when 'default' puts DefaultRenderer.new(search.results, color: color_enabled?).render when 'oneline' puts OnelineRenderer.new(search.results, color: color_enabled?).render else exit_with_message(1, 'Unsupported format: %s' % [output_format]) end end def pattern args[0] end def output_format @output_format ||= options['format'] || DEFAULT_FORMAT end def include_all? !!(options['all'] || options['a']) end private def repository @repository ||= I18nFlow::Repository.new( base_path: I18nFlow.config.base_path, glob_patterns: I18nFlow.config.glob_patterns, ) end def search @search ||= I18nFlow::Search.new( repository: repository, pattern: pattern, include_all: include_all?, ) end end end
Version data entries
5 entries across 5 versions & 1 rubygems