diff --git a/Grabazine.go b/Grabazine.go index 5c6992b..99cdd97 100644 --- a/Grabazine.go +++ b/Grabazine.go @@ -7,6 +7,7 @@ import ( "fmt" wkhtml "github.com/SebastiaanKlippert/go-wkhtmltopdf" "github.com/pdfcpu/pdfcpu/pkg/api" + "github.com/tidwall/gjson" "io/ioutil" "log" "net/http" @@ -38,6 +39,34 @@ func main() { flag.Parse() + mydir, err := os.Getwd() + if err != nil { + fmt.Println(err) + } + + if fileExists(mydir + "/config.json") { + fmt.Println("Config file loaded") + byteValue, _ := ioutil.ReadFile("config.json") + username := gjson.GetBytes(byteValue, "username") + if username.Exists() { + *usernamePtr = username.String() + fmt.Println("Username taken from config file") + } + + password := gjson.GetBytes(byteValue, "password") + if password.Exists() { + *passwordPtr = password.String() + fmt.Println("password taken from config file") + } + + chrome := gjson.GetBytes(byteValue, "chromepath") + if chrome.Exists() { + *chromePtr = chrome.String() + fmt.Println("chromepath taken from config file") + } + + } + fmt.Println("Starting the application...") initialToken, err := GetInitialToken() if err != nil { @@ -58,10 +87,6 @@ func main() { template = []byte(defaultTemplate) } - mydir, err := os.Getwd() - if err != nil { - fmt.Println(err) - } fmt.Println("Resolved working directory to: " + mydir) //fmt.Println("Grabbing list of pages...") if _, err := os.Stat(mydir + "/issue/"); os.IsNotExist(err) { diff --git a/built/Zinigo_Linux_AMD64 b/built/Zinigo_Linux_AMD64 index e161523..dfb74d3 100644 Binary files a/built/Zinigo_Linux_AMD64 and b/built/Zinigo_Linux_AMD64 differ diff --git a/built/Zinigo_Windows_x64.exe b/built/Zinigo_Windows_x64.exe index 26cbebd..c468cb1 100644 Binary files a/built/Zinigo_Windows_x64.exe and b/built/Zinigo_Windows_x64.exe differ diff --git a/config.json b/config.json new file mode 100644 index 0000000..1476bdb --- /dev/null +++ b/config.json @@ -0,0 +1,5 @@ +{ + "username":"zinio user name", + "password":"zinio password", + "chromepath":"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" +} \ No newline at end of file