Sha256: 3808d13de5e9011ef6ceb3b7535459025418fdf48c985f431b78692f8177522b

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.2 exe/githelp