Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xindoo
redis
提交
50d0e82d
R
redis
项目概览
xindoo
/
redis
通知
2
Star
2
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
redis
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
50d0e82d
编写于
11月 28, 2010
作者:
P
Pieter Noordhuis
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update help.h generator script to output man-style argument list
上级
2612e052
变更
2
展开全部
显示空白变更内容
内联
并排
Showing
2 changed file
with
628 addition
and
739 deletion
+628
-739
src/help.h
src/help.h
+580
-694
utils/generate-command-help.rb
utils/generate-command-help.rb
+48
-45
未找到文件。
src/help.h
浏览文件 @
50d0e82d
此差异已折叠。
点击以展开。
utils/generate-command-help.rb
浏览文件 @
50d0e82d
#!/usr/bin/env ruby
#!/usr/bin/env ruby
require
'net/http'
require
'net/https'
require
'json'
require
'uri'
dest
=
ARGV
[
0
]
tmpl
=
File
.
read
'./utils/help.h'
url
=
URI
.
parse
'https://github.com/antirez/redis-doc/raw/master/commands.json'
client
=
Net
::
HTTP
.
new
url
.
host
,
url
.
port
client
.
use_ssl
=
true
res
=
client
.
get
url
.
path
def
argument
arg
def
argument
arg
name
=
arg
[
'name'
].
is_a?
(
Array
)
?
arg
[
'name'
].
join
(
' '
)
:
arg
[
'name'
]
name
=
arg
[
"name"
].
is_a?
(
Array
)
?
arg
[
"name"
].
join
(
" "
)
:
arg
[
"name"
]
name
=
arg
[
'enum'
].
join
'|'
if
'enum'
==
arg
[
'type'
]
name
=
arg
[
"enum"
].
join
"|"
if
"enum"
==
arg
[
"type"
]
name
=
arg
[
'command'
]
+
' '
+
name
if
arg
[
'command'
]
name
=
arg
[
"command"
]
+
" "
+
name
if
arg
[
"command"
]
if
arg
[
'multiple'
]
if
arg
[
"multiple"
]
name
=
"
(
#{
name
}
)
"
name
=
"
#{
name
}
[
#{
name
}
...]
"
name
+=
arg
[
'optional'
]
?
'*'
:
'+'
end
elsif
arg
[
'optional'
]
if
arg
[
"optional"
]
name
=
"
(
#{
name
}
)?
"
name
=
"
[
#{
name
}
]
"
end
end
name
name
end
end
def
arguments
command
def
arguments
command
return
'-'
unless
command
[
'arguments'
]
return
"-"
unless
command
[
"arguments"
]
command
[
'arguments'
].
map
do
|
arg
|
command
[
"arguments"
].
map
do
|
arg
|
argument
arg
argument
arg
end
.
join
' '
end
.
join
" "
end
end
case
res
def
commands
when
Net
::
HTTPSuccess
return
@commands
if
@commands
first
=
true
commands
=
JSON
.
parse
(
res
.
body
)
require
"net/http"
c
=
commands
.
map
do
|
key
,
command
|
require
"net/https"
buf
=
if
first
require
"json"
first
=
false
require
"uri"
' '
url
=
URI
.
parse
"https://github.com/antirez/redis-doc/raw/master/commands.json"
client
=
Net
::
HTTP
.
new
url
.
host
,
url
.
port
client
.
use_ssl
=
true
response
=
client
.
get
url
.
path
if
response
.
is_a?
(
Net
::
HTTPSuccess
)
@commands
=
JSON
.
parse
(
response
.
body
)
else
else
"
\n
,"
response
.
error!
end
end
buf
+=
" {
\"
#{
key
}
\"\n
"
+
" ,
\"
#{
arguments
(
command
)
}
\"\n
"
+
" ,
\"
#{
command
[
'summary'
]
}
\"\n
"
+
" , COMMAND_GROUP_
#{
command
[
'group'
].
upcase
}
\n
"
+
" ,
\"
#{
command
[
'since'
]
}
\"
}"
end
.
join
(
"
\n
"
)
puts
"
\n
// Auto-generated, do not edit.
\n
"
+
tmpl
.
sub
(
'__COMMANDS__'
,
c
)
else
res
.
error!
end
end
def
generate_commands
commands
.
to_a
.
sort
do
|
x
,
y
|
x
[
0
]
<=>
y
[
0
]
end
.
map
do
|
key
,
command
|
<<-
SPEC
{ "
#{
key
}
",
"
#{
arguments
(
command
)
}
",
"
#{
command
[
"summary"
]
}
",
COMMAND_GROUP_
#{
command
[
"group"
].
upcase
}
,
"
#{
command
[
"since"
]
}
" }
SPEC
end
.
join
(
", "
)
end
# Write to stdout
tmpl
=
File
.
read
"./utils/help.h"
puts
"
\n
// Auto-generated, do not edit.
\n
"
+
tmpl
.
sub
(
"__COMMANDS__"
,
generate_commands
)
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录