Verified Commit a326a3f7 authored by Marcel's avatar Marcel

Return errors to cobra

parent a9a4a223
......@@ -25,10 +25,10 @@ var rootCmd = &cobra.Command{
Short: "LuftdatenImage is a simple luftdaten.info web screenshoter",
Long: `A simple headless screenshot Tool for luftdaten.info build with golang and Google Chrome`,
Version: "0.1.0",
Run: Run,
RunE: Run,
}
func Run(cmd *cobra.Command, args []string) {
func Run(cmd *cobra.Command, args []string) error {
var err error
// create context
......@@ -81,27 +81,28 @@ func Run(cmd *cobra.Command, args []string) {
c, err := chromedp.New(ctxt, opts)
if err != nil {
log.Fatal(err)
return err
}
// run task list
err = c.Run(ctxt, actions.Screenshot(`http://deutschland.maps.luftdaten.info/`, FolderPath))
if err != nil {
log.Fatal(err)
return err
}
// shutdown chrome
err = c.Shutdown(ctxt)
if err != nil {
log.Fatal(err)
return err
}
log.Println("waiting for headless_shell to exit...")
// wait for chrome to finish
// TODO: Hope that Wait can be used again in the future
/*err = c.Wait()
if err != nil {
log.Fatal(err)
return err
}*/
return nil
}
func Execute() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment