Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
c814478f
提交
c814478f
authored
5月 31, 2016
作者:
Jeromy Johnson
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2773 from ipfs/feature/commands-flags
Fix commands --flags not showing flags via HTTP API
上级
88da12ef
7167e93b
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
51 行增加
和
14 行删除
+51
-14
commands.go
core/commands/commands.go
+20
-14
t0500-issues-and-regressions-offline.sh
test/sharness/t0500-issues-and-regressions-offline.sh
+11
-0
t0501-issues-and-regressions-online.sh
test/sharness/t0501-issues-and-regressions-online.sh
+20
-0
没有找到文件。
core/commands/commands.go
浏览文件 @
c814478f
...
...
@@ -17,8 +17,11 @@ import (
type
Command
struct
{
Name
string
Subcommands
[]
Command
Options
[]
cmds
.
Option
ShowOptions
bool
Options
[]
Option
}
type
Option
struct
{
Names
[]
string
}
const
(
...
...
@@ -37,15 +40,15 @@ func CommandsCmd(root *cmds.Command) *cmds.Command {
cmds
.
BoolOption
(
flagsOptionName
,
"f"
,
"Show command flags"
)
.
Default
(
false
),
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
showOptions
,
_
,
_
:=
req
.
Option
(
flagsOptionName
)
.
Bool
()
rootCmd
:=
cmd2outputCmd
(
"ipfs"
,
root
,
showOptions
)
rootCmd
:=
cmd2outputCmd
(
"ipfs"
,
root
)
res
.
SetOutput
(
&
rootCmd
)
},
Marshalers
:
cmds
.
MarshalerMap
{
cmds
.
Text
:
func
(
res
cmds
.
Response
)
(
io
.
Reader
,
error
)
{
v
:=
res
.
Output
()
.
(
*
Command
)
showOptions
,
_
,
_
:=
res
.
Request
()
.
Option
(
flagsOptionName
)
.
Bool
()
buf
:=
new
(
bytes
.
Buffer
)
for
_
,
s
:=
range
cmdPathStrings
(
v
)
{
for
_
,
s
:=
range
cmdPathStrings
(
v
,
showOptions
)
{
buf
.
Write
([]
byte
(
s
+
"
\n
"
))
}
return
buf
,
nil
...
...
@@ -55,35 +58,38 @@ func CommandsCmd(root *cmds.Command) *cmds.Command {
}
}
func
cmd2outputCmd
(
name
string
,
cmd
*
cmds
.
Command
,
showOptions
bool
)
Command
{
func
cmd2outputCmd
(
name
string
,
cmd
*
cmds
.
Command
)
Command
{
opts
:=
make
([]
Option
,
len
(
cmd
.
Options
))
for
i
,
opt
:=
range
cmd
.
Options
{
opts
[
i
]
=
Option
{
opt
.
Names
()}
}
output
:=
Command
{
Name
:
name
,
Subcommands
:
make
([]
Command
,
len
(
cmd
.
Subcommands
)),
Options
:
cmd
.
Options
,
ShowOptions
:
showOptions
,
Options
:
opts
,
}
i
:=
0
for
name
,
sub
:=
range
cmd
.
Subcommands
{
output
.
Subcommands
[
i
]
=
cmd2outputCmd
(
name
,
sub
,
showOptions
)
output
.
Subcommands
[
i
]
=
cmd2outputCmd
(
name
,
sub
)
i
++
}
return
output
}
func
cmdPathStrings
(
cmd
*
Command
)
[]
string
{
func
cmdPathStrings
(
cmd
*
Command
,
showOptions
bool
)
[]
string
{
var
cmds
[]
string
var
recurse
func
(
prefix
string
,
cmd
*
Command
)
recurse
=
func
(
prefix
string
,
cmd
*
Command
)
{
newPrefix
:=
prefix
+
cmd
.
Name
cmds
=
append
(
cmds
,
newPrefix
)
if
prefix
!=
""
&&
cmd
.
ShowOptions
{
for
_
,
option
:=
range
cmd
.
Options
{
names
:=
option
.
Names
()
if
prefix
!=
""
&&
showOptions
{
for
_
,
options
:=
range
cmd
.
Options
{
var
cmdOpts
[]
string
for
_
,
flag
:=
range
n
ames
{
for
_
,
flag
:=
range
options
.
N
ames
{
if
len
(
flag
)
==
1
{
flag
=
"-"
+
flag
}
else
{
...
...
test/sharness/t0500-issues-and-regressions-offline.sh
0 → 100755
浏览文件 @
c814478f
#!/bin/sh
test_description
=
"Tests for various fxed issues and regressions."
.
lib/test-lib.sh
test_init_ipfs
# Tests go here
test_done
test/sharness/t0501-issues-and-regressions-online.sh
0 → 100755
浏览文件 @
c814478f
#!/bin/sh
test_description
=
"Tests for various fxed issues and regressions."
.
lib/test-lib.sh
test_init_ipfs
test_launch_ipfs_daemon
# Tests go here
test_expect_sucess
"commands command with flag flags works via HTTP API - #2301"
'
curl "http://$API_ADDR/api/v0/commands?flags" | grep "verbose"
'
test_kill_ipfs_daemon
test_done
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论