refactor(command): modify int to int64
License: MIT Signed-off-by: Overbool <overbool.xu@gmail.com>
Overbool committed
Oct 18, 2018 at 23:33 UTC
ff6f16c939e264c12884a424caec658e44236bcf
2 files changed
+12
-12
core/commands/cat.go
+4
-4
@@ -29,8 +29,8 @@ var CatCmd = &cmds.Command{
29
cmdkit.StringArg("ipfs-path", true, true, "The path to the IPFS object(s) to be outputted.").EnableStdin(),
30
},
31
Options: []cmdkit.Option{
32
- cmdkit.IntOption(offsetOptionName, "o", "Byte offset to begin reading from."),
33
- cmdkit.IntOption(lengthOptionName, "l", "Maximum number of bytes to read."),
32
+ cmdkit.Int64Option(offsetOptionName, "o", "Byte offset to begin reading from."),
33
+ cmdkit.Int64Option(lengthOptionName, "l", "Maximum number of bytes to read."),
34
},
35
Run: func(req *cmds.Request, res cmds.ResponseEmitter, env cmds.Environment) error {
36
node, err := cmdenv.GetNode(env)
@@ -49,12 +49,12 @@ var CatCmd = &cmds.Command{
49
}
50
}
51
52
- offset, _ := req.Options[offsetOptionName].(int)
52
+ offset, _ := req.Options[offsetOptionName].(int64)
53
if offset < 0 {
54
return fmt.Errorf("cannot specify negative offset")
55
}
56
57
- max, found := req.Options[lengthOptionName].(int)
57
+ max, found := req.Options[lengthOptionName].(int64)
58
if err != nil {
59
return err
60
}
core/commands/files.go
+8
-8
@@ -564,8 +564,8 @@ Examples:
564
cmdkit.StringArg("path", true, false, "Path to file to be read."),
565
},
566
Options: []cmdkit.Option{
567
- cmdkit.IntOption(filesOffsetOptionName, "o", "Byte offset to begin reading from."),
568
- cmdkit.IntOption(filesCountOptionName, "n", "Maximum number of bytes to read."),
567
+ cmdkit.Int64Option(filesOffsetOptionName, "o", "Byte offset to begin reading from."),
568
+ cmdkit.Int64Option(filesCountOptionName, "n", "Maximum number of bytes to read."),
569
},
570
Run: func(req oldcmds.Request, res oldcmds.Response) {
571
n, err := req.InvocContext().GetNode()
@@ -600,7 +600,7 @@ Examples:
600
601
defer rfd.Close()
602
603
- offset, _, err := req.Option(offsetOptionName).Int()
603
+ offset, _, err := req.Option(offsetOptionName).Int64()
604
if err != nil {
605
res.SetError(err, cmdkit.ErrNormal)
606
return
@@ -628,7 +628,7 @@ Examples:
628
}
629
630
var r io.Reader = &contextReaderWrapper{R: rfd, ctx: req.Context()}
631
- count, found, err := req.Option(filesCountOptionName).Int()
631
+ count, found, err := req.Option(filesCountOptionName).Int64()
632
if err != nil {
633
res.SetError(err, cmdkit.ErrNormal)
634
return
@@ -750,11 +750,11 @@ stat' on the file or any of its ancestors.
750
cmdkit.FileArg("data", true, false, "Data to write.").EnableStdin(),
751
},
752
Options: []cmdkit.Option{
753
- cmdkit.IntOption(filesOffsetOptionName, "o", "Byte offset to begin writing at."),
753
+ cmdkit.Int64Option(filesOffsetOptionName, "o", "Byte offset to begin writing at."),
754
cmdkit.BoolOption(filesCreateOptionName, "e", "Create the file if it does not exist."),
755
cmdkit.BoolOption(filesParentsOptionName, "p", "Make parent directories as needed."),
756
cmdkit.BoolOption(filesTruncateOptionName, "t", "Truncate the file to size zero before writing."),
757
- cmdkit.IntOption(filesCountOptionName, "n", "Maximum number of bytes to read."),
757
+ cmdkit.Int64Option(filesCountOptionName, "n", "Maximum number of bytes to read."),
758
cmdkit.BoolOption(filesRawLeavesOptionName, "Use raw blocks for newly created leaf nodes. (experimental)"),
759
cidVersionOption,
760
hashOption,
@@ -781,7 +781,7 @@ stat' on the file or any of its ancestors.
781
return err
782
}
783
784
- offset, _ := req.Options[filesOffsetOptionName].(int)
784
+ offset, _ := req.Options[filesOffsetOptionName].(int64)
785
if offset < 0 {
786
return fmt.Errorf("cannot have negative write offset")
787
}
@@ -823,7 +823,7 @@ stat' on the file or any of its ancestors.
823
}
824
}
825
826
- count, countfound := req.Options[filesCountOptionName].(int)
826
+ count, countfound := req.Options[filesCountOptionName].(int64)
827
if countfound && count < 0 {
828
return fmt.Errorf("cannot have negative byte count")
829
}