Skip to content

Commit

Permalink
flags instead of getopt, push go.sum
Browse files Browse the repository at this point in the history
  • Loading branch information
LordRusk committed Jan 4, 2021
1 parent f0d73d9 commit a5bc5db
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@ module github.com/lordrusk/goscrape

go 1.15

require (
github.com/mtarnawa/godesu v1.0.0
github.com/pborman/getopt v1.1.0
)
require github.com/mtarnawa/godesu v1.0.0
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
github.com/mtarnawa/godesu v1.0.0 h1:i3W32K/ghhf9qaA7gRjS2dgDGXkByvonzgTHfO2AVRE=
github.com/mtarnawa/godesu v1.0.0/go.mod h1:GCnGaXjQp0BH6BQpvZvZfRwKLCeY4tzSFi2WMAGNcjA=
24 changes: 14 additions & 10 deletions main.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package main

import (
"flag"
"fmt"
"io"
"net/http"
Expand All @@ -9,7 +10,6 @@ import (
"strings"

"github.com/mtarnawa/godesu"
"github.com/pborman/getopt"
)

type finishState struct {
Expand All @@ -18,26 +18,30 @@ type finishState struct {
}

var ( // opts
help = getopt.BoolLong("help", 'h', "Help")
useOrigFilename = getopt.BoolLong("useOrigFilename", 'o', "Download with the original filename")
customDownloadDir = getopt.StringLong("customDownloadDir", 'c', "", "Set a custom directory for the images to download to")
help = flag.Bool("h", false, "Show help menu")
useOrigFilename = flag.Bool("o", false, "Download with the original filename")
customDownloadDir = flag.String("c", "", "Set a custom directory for the images to download to")
)

func main() {
getopt.Parse()
flag.Parse()
if *help {
getopt.Usage()
flag.Usage()
return
}

args := getopt.Args()
args := flag.Args()
if len(args) < 1 {
getopt.Usage()
flag.Usage()
return
}

urls := strings.Split(args[0], " ")
origDir, _ := os.Getwd()
origDir, err := os.Getwd()
if err != nil {
fmt.Printf("Could not grab working directory! | %v\n", err)
return
}
Gochan := godesu.New()

for urlNum, url := range urls { // loop through all urls
Expand Down Expand Up @@ -71,7 +75,7 @@ func main() {
fmt.Printf("Cannot create directory! %v\n", err)
return
}

os.Chdir(purl[3] + "/" + purl[5])
}

Expand Down

0 comments on commit a5bc5db

Please sign in to comment.