Sha256: 75424aabb4a49381c70f5be19543324d8f2415f291cebd8d35c061317be48752
Contents?: true
Size: 1.74 KB
Versions: 3
Compression:
Stored size: 1.74 KB
Contents
#!/usr/bin/env ruby require 'clausewitz/spelling/checker' require 'optimist' class Main def initialize(args) @opts, @args = parse_args(args) end def parse_args(args) opts = Optimist::options(args) do opt :custom_dicts, "List of custom dictionaries to load", type: :strings opt :custom_dict_root, "Directory containing per-language-dialect custom dicts", type: :string opt :suggestion_count, "How many suggestions to display", type: :int opt :verbose, "Whether to display additional output while running", default: false Clausewitz::Localisation::LANG_MAP.each do |_, config| opt "#{config.name}_dialect".to_sym, "Select dialect for #{config.name.capitalize}", type: :string end end dialect_map = {} dialect_opts = opts.keys.select { |k| k =~ /.+_dialect/ } dialect_opts.each do |dialect_opt_key| next unless opts[dialect_opt_key] next if dialect_opt_key.to_s.end_with?('given') language_name = dialect_opt_key[/(.+)_dialect/, 1] dialect_map[language_name] = opts[dialect_opt_key] end checker_opts = {} checker_opts[:custom_dict_root] = opts[:custom_dict_root] checker_opts[:custom_dicts] = opts[:custom_dicts] checker_opts[:dialect_map] = dialect_map checker_opts[:suggestion_count] = opts[:suggestion_count] checker_opts[:verbose] = opts[:verbose] [checker_opts, args] end def run spellchecker = Clausewitz::Spelling::Checker.new(@opts) results = @args.map { |arg| spellchecker.check_file(arg) } results.each { |r| puts r } !results.any?(&:failed?) end end exit(Main.new(ARGV).run) # vim: set ft=ruby ts=2 sw=2 tw=79 :
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
clausewitz-spelling-0.2.6 | exe/clausewitz-spellcheck |
clausewitz-spelling-0.2.5 | exe/clausewitz-spellcheck |
clausewitz-spelling-0.2.4 | exe/clausewitz-spellcheck |