Skip to content
This repository has been archived by the owner on May 27, 2020. It is now read-only.

Commit

Permalink
#3 Add offset start flag
Browse files Browse the repository at this point in the history
  • Loading branch information
hleb-albau committed Feb 9, 2019
1 parent 4bb9087 commit 1b013ad
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion cyber/cyber_submit.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ import (
"os"
)

// todo add state save
func SubmitLinksToCyberCmd() *cobra.Command {
cmd := cobra.Command{
Use: "submit-links-to-cyber <path-to-wiki-titles-file>",
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) error {

chunkSize := viper.GetInt("chunk")
offset := viper.GetInt64("offset")

ipfsClient := ipfs.Open()
wikiReader, err := wiki.OpenTitlesReader(args[0])
Expand All @@ -46,6 +46,9 @@ func SubmitLinksToCyberCmd() *cobra.Command {
}
return err
}
if offset >= counter {
continue
}

page := ipfs.RawContentHash(wiki.Dura(title))
for _, keyword := range keywords {
Expand Down Expand Up @@ -81,12 +84,14 @@ func SubmitLinksToCyberCmd() *cobra.Command {
cmd.Flags().String(client.FlagNode, "127.0.0.1:26657", "Url of node communicate with")
cmd.Flags().String(client.FlagHome, homeDir+"/.cyberdcli", "Cyberd CLI home folder")
cmd.Flags().Int("chunk", 1000, "How many links put into single transaction")
cmd.Flags().Int64("offset", 0, "How many pages to skip, before submitting links")

_ = viper.BindPFlag(client.FlagPassphrase, cmd.Flags().Lookup(client.FlagPassphrase))
_ = viper.BindPFlag(client.FlagAddress, cmd.Flags().Lookup(client.FlagAddress))
_ = viper.BindPFlag(client.FlagNode, cmd.Flags().Lookup(client.FlagNode))
_ = viper.BindPFlag(client.FlagHome, cmd.Flags().Lookup(client.FlagHome))
_ = viper.BindPFlag("chunk", cmd.Flags().Lookup("chunk"))
_ = viper.BindPFlag("offset", cmd.Flags().Lookup("offset"))

return &cmd
}
Expand Down

0 comments on commit 1b013ad

Please # to comment.