-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cmd.Config): re-add support for configuration files
thanks to gateway nodes dying, we need a way to modify our bootstrap list. To do this the right way, I've brought back config.json, this time stored in $QRI_PATH. We've also added a new command "boostrap" that allows listing, adding, and removing bootstrap addresses. closes #108
- Loading branch information
Showing
12 changed files
with
158 additions
and
98 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package cmd | ||
|
||
import ( | ||
"github.com/qri-io/qri/p2p" | ||
"github.com/spf13/cobra" | ||
"github.com/spf13/viper" | ||
) | ||
|
||
// bootstrapCmd represents the bootstrap command | ||
var bootstrapCmd = &cobra.Command{ | ||
Use: "bootstrap", | ||
Aliases: []string{"bs"}, | ||
Short: "show or edit the list of qri bootstrap peers", | ||
} | ||
|
||
var bootstrapListCmd = &cobra.Command{ | ||
Use: "list", | ||
Aliases: []string{"ls"}, | ||
Short: "Show a configuration setting", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
list := viper.GetStringSlice("bootstrap") | ||
for _, i := range list { | ||
PrintInfo("%s\n", i) | ||
} | ||
}, | ||
} | ||
|
||
var boostrapAddCmd = &cobra.Command{ | ||
Use: "add", | ||
Short: "add peers to the bootstrap list", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
_, err := p2p.ParseMultiaddrs(args) | ||
ExitIfErr(err) | ||
addrs := append(viper.GetStringSlice("bootstrap"), args...) | ||
// TODO - fix!!! | ||
WriteConfigFile(&Config{Bootstrap: addrs}) | ||
}, | ||
} | ||
|
||
var boostrapRmCmd = &cobra.Command{ | ||
Use: "remove", | ||
Aliases: []string{"rm"}, | ||
Short: "remove peers from the bootstrap list", | ||
Run: func(cmd *cobra.Command, args []string) { | ||
addrs := viper.GetStringSlice("bootstrap") | ||
for _, rm := range args { | ||
for i, adr := range addrs { | ||
if rm == adr { | ||
addrs = append(addrs[:i], addrs[i+1:]...) | ||
} | ||
} | ||
} | ||
// TODO - fix!!! | ||
WriteConfigFile(&Config{Bootstrap: addrs}) | ||
}, | ||
} | ||
|
||
func init() { | ||
bootstrapCmd.AddCommand(bootstrapListCmd) | ||
bootstrapCmd.AddCommand(boostrapAddCmd) | ||
bootstrapCmd.AddCommand(boostrapRmCmd) | ||
RootCmd.AddCommand(bootstrapCmd) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters