Add optional link argument

master
blank X 10 months ago
parent 3fdc170db8
commit 3be014a4a8
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
  1. 10
      main.go

@ -17,8 +17,8 @@ import (
)
func main() {
if len(os.Args) != 2 {
fmt.Fprintf(os.Stderr, "Usage: %s <submission id/url>\n", os.Args[0])
if len(os.Args) != 2 && len(os.Args) != 3 {
fmt.Fprintf(os.Stderr, "Usage: %s <submission id/url> [direct url to download instead of inferring from the post]\n", os.Args[0])
os.Exit(1)
}
LoadMimetypes()
@ -215,7 +215,11 @@ func main() {
break
}
}
unparsedUrl = urls[i]
if len(os.Args) == 3 {
unparsedUrl = os.Args[2]
} else {
unparsedUrl = urls[i]
}
response, err := client.Get(unparsedUrl)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to get response: %s\n", err)