Add optional link argument
This commit is contained in:
parent
3fdc170db8
commit
3be014a4a8
8
main.go
8
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
|
||||
}
|
||||
}
|
||||
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)
|
||||
|
|
Reference in New Issue