Add optional link argument
This commit is contained in:
parent
3fdc170db8
commit
3be014a4a8
10
main.go
10
main.go
|
@ -17,8 +17,8 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if len(os.Args) != 2 {
|
if len(os.Args) != 2 && len(os.Args) != 3 {
|
||||||
fmt.Fprintf(os.Stderr, "Usage: %s <submission id/url>\n", os.Args[0])
|
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)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
LoadMimetypes()
|
LoadMimetypes()
|
||||||
|
@ -215,7 +215,11 @@ func main() {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
unparsedUrl = urls[i]
|
if len(os.Args) == 3 {
|
||||||
|
unparsedUrl = os.Args[2]
|
||||||
|
} else {
|
||||||
|
unparsedUrl = urls[i]
|
||||||
|
}
|
||||||
response, err := client.Get(unparsedUrl)
|
response, err := client.Get(unparsedUrl)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Fprintf(os.Stderr, "Failed to get response: %s\n", err)
|
fmt.Fprintf(os.Stderr, "Failed to get response: %s\n", err)
|
||||||
|
|
Reference in New Issue