]>
git.saurik.com Git - redis.git/blob - utils/generate-command-help.rb
9 tmpl
= File
.read
'./utils/help.h'
11 url
= URI
.parse
'https://github.com/antirez/redis-doc/raw/master/commands.json'
12 client
= Net
::HTTP.new url
.host
, url
.port
14 res
= client
.get url
.path
17 name
= arg
['name'].is_a
?(Array
) ? arg
['name'].join(' ') : arg
['name']
18 name
= arg
['enum'].join
'|' if 'enum' == arg
['type']
19 name
= arg
['command'] +
' ' + name
if arg
['command']
22 name +
= arg
['optional'] ? '*' : '+'
30 return '-' unless command['arguments
']
31 command['arguments
'].map do |arg|
39 commands = JSON.parse(res.body)
40 c = commands.map do |key, command|
47 buf += " { \"#{key}\"\n" +
48 " , \"#{arguments(command)}\"\n" +
49 " , \"#{command['summary']}\"\n" +
50 " , COMMAND_GROUP_#{command['group'].upcase}\n" +
51 " , \"#{command['since']}\" }"
53 puts
"\n// Auto-generated, do not edit.\n" + tmpl
.sub('__COMMANDS__', c
)