mirror of
https://github.com/NohamR/papeer.git
synced 2026-05-26 13:00:59 +00:00
add threads option
This commit is contained in:
12
cmd/get.go
12
cmd/get.go
@@ -17,7 +17,7 @@ import (
|
||||
|
||||
var stdout, recursive, include, images bool
|
||||
var format, output, selector string
|
||||
var limit, offset, delay int
|
||||
var limit, offset, delay, threads int
|
||||
|
||||
var getCmd = &cobra.Command{
|
||||
Use: "get",
|
||||
@@ -68,11 +68,19 @@ var getCmd = &cobra.Command{
|
||||
return errors.New("cannot use delay option if not in recursive mode")
|
||||
}
|
||||
|
||||
if cmd.Flags().Changed("threads") && recursive == false {
|
||||
return errors.New("cannot use threads option if not in recursive mode")
|
||||
}
|
||||
|
||||
if cmd.Flags().Changed("delay") && cmd.Flags().Changed("threads") {
|
||||
return errors.New("cannot use delay and threads options at the same time")
|
||||
}
|
||||
|
||||
return nil
|
||||
},
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
url := args[0]
|
||||
b := book.NewBookFromURL(url, selector, recursive, include, images, limit, offset, delay)
|
||||
b := book.NewBookFromURL(url, selector, recursive, include, images, limit, offset, delay, threads)
|
||||
|
||||
if len(output) == 0 {
|
||||
// set default output
|
||||
|
||||
@@ -33,6 +33,7 @@ func init() {
|
||||
rootCmd.PersistentFlags().IntVarP(&limit, "limit", "l", -1, "limit number of chapters, in recursive mode")
|
||||
rootCmd.PersistentFlags().IntVarP(&offset, "offset", "o", 0, "skip first chapters, in recursive mode")
|
||||
rootCmd.PersistentFlags().IntVarP(&delay, "delay", "d", -1, "time to wait before downloading next chapter, in milliseconds")
|
||||
rootCmd.PersistentFlags().IntVarP(&threads, "threads", "t", -1, "download concurrency, in recursive mode")
|
||||
|
||||
rootCmd.AddCommand(getCmd)
|
||||
rootCmd.AddCommand(listCmd)
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package cmd
|
||||
|
||||
func getTableOfContent() {
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user