Sha256: 5a0543639207d3dd6cf52a6ce82a2f0b4ad2817acecf5554a4b90148080b136c

Contents?: true

Size: 941 Bytes

Versions: 3

Compression:

Stored size: 941 Bytes

Contents

module Wdim

  DICTIONARY_PATH = File.expand_path("../../../config/dictionary.yml", __FILE__)

  class CLI

    attr_accessor :decoratable

    def initialize
      @commands = YAML.load_file(DICTIONARY_PATH)
      @decoratable = false
    end

    def start(argv)
      # TODO: parse args and use as options
      print_meaning(argv[0])
    end

    def print_meaning(term)
      puts @decoratable ? decorate(search(term)) : search(term)
    end

    def search(term)
      @commands[term] || "Not registered in dictionary."
    end

    def decorate(meaning)
      # TODO: more decorations
      # 作業中にパッと目につく感じにしたいけど、そうすると grep `wdim cd` dictionary.yml みたいな使い方ができなくなる
      # .wdimrc あるいはオプションで指定したい
      "----------------------------------------\n\t#{meaning}\t\n----------------------------------------"
    end
    
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
wdim-0.1.2 lib/wdim/cli.rb
wdim-0.1.1 lib/wdim/cli.rb
wdim-0.1.0 lib/wdim/cli.rb