Sha256: 47faf297a9409a7b5f99a1d730cc91196da4e8c404dd196e4bc6a4e293db2505
Contents?: true
Size: 1.05 KB
Versions: 5
Compression:
Stored size: 1.05 KB
Contents
#!/usr/bin/env ruby require 'githelp' include GitHelp require 're_expand' require 'json' DATAFILE = File.expand_path("~/.githelp") if !File.exist?(DATAFILE) STDERR.puts "GitHelpデータ「#{DATAFILE}」が存在しません。" STDERR.puts "getghdata コマンドで作成して下さい。" exit end 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
5 entries across 5 versions & 1 rubygems
Version | Path |
---|---|
githelp-0.2.11 | exe/githelp |
githelp-0.2.10 | exe/githelp |
githelp-0.2.9 | exe/githelp |
githelp-0.2.8 | exe/githelp |
githelp-0.2.7 | exe/githelp |