Sha256: e70b16c4691bbb4a9d5fd29319c2b265b90d7f9cac6884eb40884332ae531d49

Contents?: true

Size: 875 Bytes

Versions: 1

Compression:

Stored size: 875 Bytes

Contents

#!/usr/bin/env ruby

include Githelp

require 're_expand'
require 'json'

DATAFILE = File.expand_path("~/.githelp")

data = JSON.parse(File.read(DATAFILE))

#
# 関数定義などをeval
#
data['codes'].each { |code|
  eval code
}

g = ExpandRuby::Generator.new # re_expandのジェネレータ

#
# GitHelpエントリ
#
lines = []

data['defs'].each { |line|
  if line =~ /^\s*\$\s*(.*)$/ # $....
    lines << $1
  elsif line =~ /^\s*\%\s*(.*)$/ # %....
    cmd = $1
    lines.each { |l|
      desc = eval('"' + l + '"')
      g.add desc.force_encoding('utf-8'), cmd.force_encoding('utf-8')
    }
    lines = []
  end
}

res = g.generate " #{args.join(' ')} "

listed = {}
list = res[0].find_all { |a| # 0 ambig
  if listed[a[1]]
    false
  else
    listed[a[1]] = true
  end
}

list.each_with_index { |entry,ind|
  puts "#[#{ind}] #{entry[0]}"
  puts "   #{entry[1]}"
}

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
githelp-0.2.1 exe/githelp