Skip to content

Commit

Permalink
fix: selector depth
Browse files Browse the repository at this point in the history
  • Loading branch information
lapwat committed Feb 6, 2022
1 parent be45a8f commit d8a3cc0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ go get -u github.com/lapwat/papeer
```sh
# use platform=darwin for MacOS
platform=linux
release=0.4.0
release=0.4.1

# download and extract
curl -L https://github.com/lapwat/papeer/releases/download/v$release/papeer-v$release-$platform-amd64.tar.gz > papeer.tar.gz
Expand All @@ -150,7 +150,7 @@ sudo mv papeer /usr/local/bin

### Windows

Download [latest release](https://github.com/lapwat/papeer/releases/download/v0.4.0/papeer-v0.4.0-windows-amd64.exe.zip).
Download [latest release](https://github.com/lapwat/papeer/releases/download/v0.4.1/papeer-v0.4.1-windows-amd64.exe.zip).

## MOBI support

Expand Down
8 changes: 7 additions & 1 deletion cmd/get.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,10 @@ var getCmd = &cobra.Command{
return errors.New("cannot use threads option if depth/selector is not specified")
}

if cmd.Flags().Changed("use-link-name") && getOpts.depth == 0 && len(getOpts.Selector) == 0 {
return errors.New("cannot use use-link-name option if depth/selector is not specified")
}

if cmd.Flags().Changed("delay") && cmd.Flags().Changed("threads") {
return errors.New("cannot use delay and threads options at the same time")
}
Expand All @@ -114,9 +118,11 @@ var getCmd = &cobra.Command{
url := args[0]

// fill selector array with empty selectors to match depth
for len(getOpts.Selector) < getOpts.depth+2 {
getOpts.Selector = append(getOpts.Selector, "")
for len(getOpts.Selector) < getOpts.depth+1 {
getOpts.Selector = append(getOpts.Selector, "")
}
fmt.Println(len(getOpts.Selector))

// generate config for each level
configs := make([]*book.ScrapeConfig, len(getOpts.Selector))
Expand Down
2 changes: 1 addition & 1 deletion cmd/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ var versionCmd = &cobra.Command{
Use: "version",
Short: "Print the version number of papeer",
Run: func(cmd *cobra.Command, args []string) {
fmt.Println("papeer v0.4.0")
fmt.Println("papeer v0.4.1")
},
}

0 comments on commit d8a3cc0

Please sign in to comment.