@cryptotaxi247 / kubo / commits / 9e67acf51

bootstrap add --default option

Juan Batiz-Benet committed Jan 6, 2015 at 04:30 UTC 9e67acf51a4788c02f0fcbf49b21dd5db6e2e902
1 file changed +25 -1
core/commands/bootstrap.go
+25 -1
@@ -63,8 +63,13 @@ in the bootstrap list).
63 },
64
65 Arguments: []cmds.Argument{
66 - cmds.StringArg("peer", true, true, peerOptionDesc),
66 + cmds.StringArg("peer", false, true, peerOptionDesc),
67 + },
68 +
69 + Options: []cmds.Option{
70 + cmds.BoolOption("default", "add default bootstrap nodes"),
71 },
72 +
73 Run: func(req cmds.Request) (interface{}, error) {
74 inputPeers, err := config.ParseBootstrapPeers(req.Arguments())
75 if err != nil {
@@ -81,11 +86,30 @@ in the bootstrap list).
86 return nil, err
87 }
88
89 + deflt, _, err := req.Option("default").Bool()
90 + if err != nil {
91 + return nil, err
92 + }
93 +
94 + if deflt {
95 + // parse separately for meaningful, correct error.
96 + defltPeers, err := DefaultBootstrapPeers()
97 + if err != nil {
98 + return nil, err
99 + }
100 +
101 + inputPeers = append(inputPeers, defltPeers...)
102 + }
103 +
104 added, err := bootstrapAdd(filename, cfg, inputPeers)
105 if err != nil {
106 return nil, err
107 }
108
109 + if len(inputPeers) == 0 {
110 + return nil, cmds.ClientError("no bootstrap peers to add")
111 + }
112 +
113 return &BootstrapOutput{added}, nil
114 },
115 Type: &BootstrapOutput{},