macearl / Wallhaven-Downloader

A simple download Script for Wallhaven.cc
126 stars 26 forks source link

[Suggestion] Read standard input to set options at runtime #7

Closed hejops closed 8 years ago

hejops commented 9 years ago

Instead of having to edit the .sh file every time you want to change some of the options (most prominently TYPE, CATEGORIES and QUERY), you could use read to set the variables.

e.g. echo "Select download method: standard (newest, oldest, random, hits, mostfav), search, favorites, useruploads" read type TYPE=$type

if [ "$TYPE" = "search" ]; then echo -n "Search term: " read query fi QUERY=$query

Very simple to implement if desired, and it makes it much nicer to use.

macearl commented 9 years ago

I actually thought about something like this multiple times. But given that most people use the script on a server or as a background job i always thought it is not necessary.

Currently Im thinking about adding arguments via getopts, so that the script could be launched like this:

./wallhaven.sh --mode search --query "SearchTerm" ...

But im still undecided about it, also i havent looked into getopts at all, so i would need to find the time for some reading into it first ;)

macearl commented 9 years ago

I finally implemented some command line arguments, let me know if this will work for you (if you still need it and havent implemented it yourself yet) or if you would prefer an interactive method, like in your comment