提交 ff6f16c9 作者: Overbool

refactor(command): modify int to int64

License: MIT
Signed-off-by: 's avatarOverbool <overbool.xu@gmail.com>
上级 9cdbb1ea
......@@ -29,8 +29,8 @@ var CatCmd = &cmds.Command{
cmdkit.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to be outputted.").EnableStdin(),
},
Options: []cmdkit.Option{
cmdkit.IntOption(offsetOptionName, "o", "Byte offset to begin reading from."),
cmdkit.IntOption(lengthOptionName, "l", "Maximum number of bytes to read."),
cmdkit.Int64Option(offsetOptionName, "o", "Byte offset to begin reading from."),
cmdkit.Int64Option(lengthOptionName, "l", "Maximum number of bytes to read."),
},
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
node, err := cmdenv.GetNode(env)
......@@ -49,12 +49,12 @@ var CatCmd = &cmds.Command{
}
}
offset, _ := req.Options[offsetOptionName].(int)
offset, _ := req.Options[offsetOptionName].(int64)
if offset < 0 {
return fmt.Errorf("cannot specify negative offset")
}
max, found := req.Options[lengthOptionName].(int)
max, found := req.Options[lengthOptionName].(int64)
if err != nil {
return err
}
......
......@@ -564,8 +564,8 @@ Examples:
cmdkit.StringArg("path", true, false, "Path to file to be read."),
},
Options: []cmdkit.Option{
cmdkit.IntOption(filesOffsetOptionName, "o", "Byte offset to begin reading from."),
cmdkit.IntOption(filesCountOptionName, "n", "Maximum number of bytes to read."),
cmdkit.Int64Option(filesOffsetOptionName, "o", "Byte offset to begin reading from."),
cmdkit.Int64Option(filesCountOptionName, "n", "Maximum number of bytes to read."),
},
Run: func(req oldcmds.Request, res oldcmds.Response) {
n, err := req.InvocContext().GetNode()
......@@ -600,7 +600,7 @@ Examples:
defer rfd.Close()
offset, _, err := req.Option(offsetOptionName).Int()
offset, _, err := req.Option(offsetOptionName).Int64()
if err != nil {
res.SetError(err, cmdkit.ErrNormal)
return
......@@ -628,7 +628,7 @@ Examples:
}
var r io.Reader = &contextReaderWrapper{R: rfd, ctx: req.Context()}
count, found, err := req.Option(filesCountOptionName).Int()
count, found, err := req.Option(filesCountOptionName).Int64()
if err != nil {
res.SetError(err, cmdkit.ErrNormal)
return
......@@ -750,11 +750,11 @@ stat' on the file or any of its ancestors.
cmdkit.FileArg("data", true, false, "Data to write.").EnableStdin(),
},
Options: []cmdkit.Option{
cmdkit.IntOption(filesOffsetOptionName, "o", "Byte offset to begin writing at."),
cmdkit.Int64Option(filesOffsetOptionName, "o", "Byte offset to begin writing at."),
cmdkit.BoolOption(filesCreateOptionName, "e", "Create the file if it does not exist."),
cmdkit.BoolOption(filesParentsOptionName, "p", "Make parent directories as needed."),
cmdkit.BoolOption(filesTruncateOptionName, "t", "Truncate the file to size zero before writing."),
cmdkit.IntOption(filesCountOptionName, "n", "Maximum number of bytes to read."),
cmdkit.Int64Option(filesCountOptionName, "n", "Maximum number of bytes to read."),
cmdkit.BoolOption(filesRawLeavesOptionName, "Use raw blocks for newly created leaf nodes. (experimental)"),
cidVersionOption,
hashOption,
......@@ -781,7 +781,7 @@ stat' on the file or any of its ancestors.
return err
}
offset, _ := req.Options[filesOffsetOptionName].(int)
offset, _ := req.Options[filesOffsetOptionName].(int64)
if offset < 0 {
return fmt.Errorf("cannot have negative write offset")
}
......@@ -823,7 +823,7 @@ stat' on the file or any of its ancestors.
}
}
count, countfound := req.Options[filesCountOptionName].(int)
count, countfound := req.Options[filesCountOptionName].(int64)
if countfound && count < 0 {
return fmt.Errorf("cannot have negative byte count")
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论