mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-29 01:12:24 +08:00
Added Default logic to ipfs init
Related to #2484 License: MIT Signed-off-by: Richard Littauer <richard.littauer@gmail.com>
This commit is contained in:
@ -17,7 +17,9 @@ import (
|
|||||||
context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
|
context "gx/ipfs/QmZy2y8t9zQH2a1b8q2ZSLKp17ATuJoCNxxyMFG5qFExpt/go-net/context"
|
||||||
)
|
)
|
||||||
|
|
||||||
const nBitsForKeypairDefault = 2048
|
const (
|
||||||
|
nBitsForKeypairDefault = 2048
|
||||||
|
)
|
||||||
|
|
||||||
var initCmd = &cmds.Command{
|
var initCmd = &cmds.Command{
|
||||||
Helptext: cmds.HelpText{
|
Helptext: cmds.HelpText{
|
||||||
@ -35,8 +37,8 @@ at ~/.ipfs. To change the repo location, set the $IPFS_PATH environment variable
|
|||||||
cmds.FileArg("default-config", false, false, "Initialize with the given configuration.").EnableStdin(),
|
cmds.FileArg("default-config", false, false, "Initialize with the given configuration.").EnableStdin(),
|
||||||
},
|
},
|
||||||
Options: []cmds.Option{
|
Options: []cmds.Option{
|
||||||
cmds.IntOption("bits", "b", fmt.Sprintf("Number of bits to use in the generated RSA private key (defaults to %d)", nBitsForKeypairDefault)),
|
cmds.IntOption("bits", "b", "Number of bits to use in the generated RSA private key.").Default(nBitsForKeypairDefault),
|
||||||
cmds.BoolOption("empty-repo", "e", "Don't add and pin help files to the local storage."),
|
cmds.BoolOption("empty-repo", "e", "Don't add and pin help files to the local storage.").Default(false),
|
||||||
|
|
||||||
// TODO need to decide whether to expose the override as a file or a
|
// TODO need to decide whether to expose the override as a file or a
|
||||||
// directory. That is: should we allow the user to also specify the
|
// directory. That is: should we allow the user to also specify the
|
||||||
@ -64,22 +66,18 @@ at ~/.ipfs. To change the repo location, set the $IPFS_PATH environment variable
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
empty, _, err := req.Option("e").Bool() // if !empty, it's okay empty == false
|
empty, _, err := req.Option("e").Bool()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.SetError(err, cmds.ErrNormal)
|
res.SetError(err, cmds.ErrNormal)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
nBitsForKeypair, bitsOptFound, err := req.Option("b").Int()
|
nBitsForKeypair, _, err := req.Option("b").Int()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
res.SetError(err, cmds.ErrNormal)
|
res.SetError(err, cmds.ErrNormal)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
if !bitsOptFound {
|
|
||||||
nBitsForKeypair = nBitsForKeypairDefault
|
|
||||||
}
|
|
||||||
|
|
||||||
var conf *config.Config
|
var conf *config.Config
|
||||||
|
|
||||||
f := req.Files()
|
f := req.Files()
|
||||||
|
Reference in New Issue
Block a user