Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
b034a0d8
提交
b034a0d8
authored
7月 09, 2016
作者:
Jeromy
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
and special case that one thing because why not
License: MIT Signed-off-by:
Jeromy
<
why@ipfs.io
>
上级
5d301cb8
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
46 行增加
和
18 行删除
+46
-18
parse.go
commands/cli/parse.go
+13
-10
client.go
commands/http/client.go
+1
-1
reqlog.go
commands/reqlog.go
+1
-1
request.go
commands/request.go
+6
-5
id.go
core/commands/id.go
+1
-1
t0120-bootstrap.sh
test/sharness/t0120-bootstrap.sh
+24
-0
没有找到文件。
commands/cli/parse.go
浏览文件 @
b034a0d8
...
...
@@ -61,6 +61,16 @@ func Parse(input []string, stdin *os.File, root *cmds.Command) (cmds.Request, *c
}
}
// This is an ugly hack to maintain our current CLI interface while fixing
// other stdin usage bugs. Let this serve as a warning, be careful about the
// choices you make, they will haunt you forever.
if
len
(
path
)
==
2
&&
path
[
0
]
==
"bootstrap"
{
if
(
path
[
1
]
==
"add"
&&
opts
[
"default"
]
==
true
)
||
(
path
[
1
]
==
"rm"
&&
opts
[
"all"
]
==
true
)
{
stdin
=
nil
}
}
stringArgs
,
fileArgs
,
err
:=
parseArgs
(
stringVals
,
stdin
,
cmd
.
Arguments
,
recursive
,
hidden
,
root
)
if
err
!=
nil
{
return
req
,
cmd
,
path
,
err
...
...
@@ -301,17 +311,10 @@ func parseArgs(inputs []string, stdin *os.File, argDefs []cmds.Argument, recursi
stringArgs
,
inputs
=
append
(
stringArgs
,
inputs
[
0
]),
inputs
[
1
:
]
}
else
{
if
stdin
!=
nil
&&
argDef
.
SupportsStdin
&&
!
fillingVariadic
{
fname
:=
""
istty
,
err
:=
isTty
(
stdin
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
if
istty
{
fname
=
stdinSpecialName
if
err
:=
printReadInfo
(
stdin
,
msgStdinInfo
);
err
==
nil
{
fileArgs
[
stdin
.
Name
()]
=
files
.
NewReaderFile
(
stdinSpecialName
,
""
,
stdin
,
nil
)
stdin
=
nil
}
fileArgs
[
stdin
.
Name
()]
=
files
.
NewReaderFile
(
fname
,
""
,
stdin
,
nil
)
stdin
=
nil
}
}
case
cmds
.
ArgFile
:
...
...
commands/http/client.go
浏览文件 @
b034a0d8
...
...
@@ -128,7 +128,7 @@ func getQuery(req cmds.Request) (string, error) {
query
.
Set
(
k
,
str
)
}
args
:=
req
.
Arguments
()
args
:=
req
.
String
Arguments
()
argDefs
:=
req
.
Command
()
.
Arguments
argDefIndex
:=
0
...
...
commands/reqlog.go
浏览文件 @
b034a0d8
...
...
@@ -56,7 +56,7 @@ func (rl *ReqLog) Add(req Request) *ReqLogEntry {
Active
:
true
,
Command
:
strings
.
Join
(
req
.
Path
(),
"/"
),
Options
:
req
.
Options
(),
Args
:
req
.
Arguments
(),
Args
:
req
.
String
Arguments
(),
ID
:
rl
.
nextID
,
req
:
req
,
log
:
rl
,
...
...
commands/request.go
浏览文件 @
b034a0d8
...
...
@@ -71,6 +71,7 @@ type Request interface {
SetOption
(
name
string
,
val
interface
{})
SetOptions
(
opts
OptMap
)
error
Arguments
()
[]
string
StringArguments
()
[]
string
SetArguments
([]
string
)
Files
()
files
.
File
SetFiles
(
files
.
File
)
...
...
@@ -168,6 +169,10 @@ func (r *request) SetOptions(opts OptMap) error {
return
r
.
ConvertOptions
()
}
func
(
r
*
request
)
StringArguments
()
[]
string
{
return
r
.
arguments
}
// Arguments returns the arguments slice
func
(
r
*
request
)
Arguments
()
[]
string
{
if
r
.
haveVarArgsFromStdin
()
{
...
...
@@ -207,7 +212,7 @@ func (r *request) haveVarArgsFromStdin() bool {
}
last
:=
r
.
cmd
.
Arguments
[
len
(
r
.
cmd
.
Arguments
)
-
1
]
return
last
.
SupportsStdin
&&
last
.
Type
==
ArgString
&&
return
last
.
SupportsStdin
&&
last
.
Type
==
ArgString
&&
(
last
.
Required
||
last
.
Variadic
)
&&
len
(
r
.
arguments
)
<
len
(
r
.
cmd
.
Arguments
)
}
...
...
@@ -234,10 +239,6 @@ func (r *request) VarArgs(f func(string) error) error {
return
err
}
if
fi
.
FileName
()
==
"*stdin*"
{
fmt
.
Fprintln
(
os
.
Stderr
,
"ipfs: Reading from stdin; send Ctrl-d to stop."
)
}
scan
:=
bufio
.
NewScanner
(
fi
)
for
scan
.
Scan
()
{
err
:=
f
(
scan
.
Text
())
...
...
core/commands/id.go
浏览文件 @
b034a0d8
...
...
@@ -58,7 +58,7 @@ EXAMPLE:
`
,
},
Arguments
:
[]
cmds
.
Argument
{
cmds
.
StringArg
(
"peerid"
,
false
,
false
,
"Peer.ID of node to look up."
)
.
EnableStdin
()
,
cmds
.
StringArg
(
"peerid"
,
false
,
false
,
"Peer.ID of node to look up."
),
},
Options
:
[]
cmds
.
Option
{
cmds
.
StringOption
(
"format"
,
"f"
,
"Optional output format."
),
...
...
test/sharness/t0120-bootstrap.sh
浏览文件 @
b034a0d8
...
...
@@ -117,6 +117,30 @@ test_bootstrap_cmd() {
'
test_bootstrap_list_cmd
test_expect_success
"'ipfs bootstrap add' accepts args from stdin"
'
echo $BP1 > bpeers &&
echo $BP2 >> bpeers &&
echo $BP3 >> bpeers &&
echo $BP4 >> bpeers &&
cat bpeers | ipfs bootstrap add > add_stdin_actual
'
test_expect_success
"output looks good"
'
test_cmp add_stdin_actual bpeers
'
test_bootstrap_list_cmd
$BP1
$BP2
$BP3
$BP4
test_expect_success
"'ipfs bootstrap rm' accepts args from stdin"
'
cat bpeers | ipfs bootstrap rm > rm_stdin_actual
'
test_expect_success
"output looks good"
'
test_cmp rm_stdin_actual bpeers
'
test_bootstrap_list_cmd
}
# should work offline
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论