Add optional link argument

This commit is contained in:
blank X 2022-02-08 16:57:14 +07:00
parent 3fdc170db8
commit 3be014a4a8
Signed by: blankie
GPG Key ID: CC15FC822C7F61F5
1 changed files with 7 additions and 3 deletions

View File

@ -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)