Sha256: 6bdecca25b24e4b9457e4d7d7b99d9b101088f1a81529732af4fd6ef7cac49d6

Contents?: true

Size: 894 Bytes

Versions: 4

Compression:

Stored size: 894 Bytes

Contents

#!/usr/bin/env ruby

require 'githelp'

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

4 entries across 4 versions & 1 rubygems

Version Path
githelp-0.2.6 exe/githelp
githelp-0.2.5 exe/githelp
githelp-0.2.4 exe/githelp
githelp-0.2.3 exe/githelp