@@ -21,9 +21,9 @@ var files string
21
21
func main () {
22
22
flag .IntVar (& day , "day" , today (), "day to download puzzle for" )
23
23
flag .IntVar (& year , "year" , time .Now ().Year (), "year to download puzzle for" )
24
- flag .StringVar (& template , "template" , " template" , "template folder" )
25
- flag .StringVar (& ide , "ide" , " goland" , "ide command to open files, must support opening files like \" $ {IDE} example\" " )
26
- flag .StringVar (& files , "files" , " puzzle.md" , "comma seperated list of files to open automatically" )
24
+ flag .StringVar (& template , "template" , osOr ( "FETCH_TEMPLATE" , " template") , "template folder" )
25
+ flag .StringVar (& ide , "ide" , osOr ( "FETCH_IDE" , " goland") , "ide command to open files, must support opening files like \" $ {IDE} example\" " )
26
+ flag .StringVar (& files , "files" , osOr ( "FETCH_FILES" , " puzzle.md") , "comma seperated list of files to open automatically" )
27
27
flag .Parse ()
28
28
29
29
if year < 100 {
@@ -76,3 +76,10 @@ func today() int {
76
76
}
77
77
return d
78
78
}
79
+
80
+ func osOr (env string , def string ) string {
81
+ if val := os .Getenv (env ); val != "" {
82
+ return val
83
+ }
84
+ return def
85
+ }
0 commit comments