Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
G
go-ipfs
概览
概览
详情
活动
周期分析
版本库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
统计图
问题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程表
图表
维基
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
jihao
go-ipfs
Commits
14975fca
提交
14975fca
authored
2月 23, 2018
作者:
fyrchik
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
make init command use go-ipfs-cmds
License: MIT Signed-off-by:
Evgenii Stratonikov
<
kraunid@gmail.com
>
上级
550c6eb5
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
14 行增加
和
28 行删除
+14
-28
init.go
cmd/ipfs/init.go
+13
-26
ipfs.go
cmd/ipfs/ipfs.go
+1
-2
没有找到文件。
cmd/ipfs/init.go
浏览文件 @
14975fca
...
...
@@ -11,13 +11,14 @@ import (
"strings"
assets
"github.com/ipfs/go-ipfs/assets"
cmds
"github.com/ipfs/go-ipfs/commands"
old
cmds
"github.com/ipfs/go-ipfs/commands"
core
"github.com/ipfs/go-ipfs/core"
namesys
"github.com/ipfs/go-ipfs/namesys"
config
"github.com/ipfs/go-ipfs/repo/config"
fsrepo
"github.com/ipfs/go-ipfs/repo/fsrepo"
"gx/ipfs/QmceUdzxkimdYsgtX733uNgzf1DLHyBKN6ehGSp85ayppM/go-ipfs-cmdkit"
"gx/ipfs/QmfAkMSt9Fwzk48QDJecPcwCUjnf2uG7MLnmCGTp4C6ouL/go-ipfs-cmds"
)
const
(
...
...
@@ -59,8 +60,9 @@ environment variable:
// name of the file?
// TODO cmdkit.StringOption("event-logs", "l", "Location for machine-readable event logs."),
},
PreRun
:
func
(
req
cmds
.
Request
)
error
{
daemonLocked
,
err
:=
fsrepo
.
LockedByOtherProcess
(
req
.
InvocContext
()
.
ConfigRoot
)
PreRun
:
func
(
req
*
cmds
.
Request
,
env
cmds
.
Environment
)
error
{
cctx
:=
env
.
(
*
oldcmds
.
Context
)
daemonLocked
,
err
:=
fsrepo
.
LockedByOtherProcess
(
cctx
.
ConfigRoot
)
if
err
!=
nil
{
return
err
}
...
...
@@ -74,30 +76,19 @@ environment variable:
return
nil
},
Run
:
func
(
req
cmds
.
Request
,
res
cmds
.
Response
)
{
// needs to be called at least once
res
.
SetOutput
(
nil
)
if
req
.
InvocContext
()
.
Online
{
Run
:
func
(
req
*
cmds
.
Request
,
res
cmds
.
ResponseEmitter
,
env
cmds
.
Environment
)
{
cctx
:=
env
.
(
*
oldcmds
.
Context
)
if
cctx
.
Online
{
res
.
SetError
(
errors
.
New
(
"init must be run offline only!"
),
cmdkit
.
ErrNormal
)
return
}
empty
,
_
,
err
:=
req
.
Option
(
"e"
)
.
Bool
()
if
err
!=
nil
{
res
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
}
nBitsForKeypair
,
_
,
err
:=
req
.
Option
(
"b"
)
.
Int
()
if
err
!=
nil
{
res
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
}
empty
,
_
:=
req
.
Options
[
"empty-repo"
]
.
(
bool
)
nBitsForKeypair
,
_
:=
req
.
Options
[
"bits"
]
.
(
int
)
var
conf
*
config
.
Config
f
:=
req
.
Files
()
f
:=
req
.
Files
if
f
!=
nil
{
confFile
,
err
:=
f
.
NextFile
()
if
err
!=
nil
{
...
...
@@ -112,18 +103,14 @@ environment variable:
}
}
profile
,
_
,
err
:=
req
.
Option
(
"profile"
)
.
String
()
if
err
!=
nil
{
res
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
}
profile
,
_
:=
req
.
Options
[
"profile"
]
.
(
string
)
var
profiles
[]
string
if
profile
!=
""
{
profiles
=
strings
.
Split
(
profile
,
","
)
}
if
err
:=
doInit
(
os
.
Stdout
,
req
.
InvocContext
()
.
ConfigRoot
,
empty
,
nBitsForKeypair
,
profiles
,
conf
);
err
!=
nil
{
if
err
:=
doInit
(
os
.
Stdout
,
cctx
.
ConfigRoot
,
empty
,
nBitsForKeypair
,
profiles
,
conf
);
err
!=
nil
{
res
.
SetError
(
err
,
cmdkit
.
ErrNormal
)
return
}
...
...
cmd/ipfs/ipfs.go
浏览文件 @
14975fca
...
...
@@ -5,7 +5,6 @@ import (
commands
"github.com/ipfs/go-ipfs/core/commands"
lgc
"github.com/ipfs/go-ipfs/commands/legacy"
cmds
"gx/ipfs/QmfAkMSt9Fwzk48QDJecPcwCUjnf2uG7MLnmCGTp4C6ouL/go-ipfs-cmds"
)
...
...
@@ -24,7 +23,7 @@ var commandsClientCmd = commands.CommandsCmd(Root)
// They can override subcommands in commands.Root by defining a subcommand with the same name.
var
localCommands
=
map
[
string
]
*
cmds
.
Command
{
"daemon"
:
daemonCmd
,
"init"
:
lgc
.
NewCommand
(
initCmd
)
,
"init"
:
initCmd
,
"commands"
:
commandsClientCmd
,
}
var
localMap
=
make
(
map
[
*
cmds
.
Command
]
bool
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论