Skip to content

Commit

Permalink
Add mac logic for specifying absolute chrome binary path
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniils Petrovs committed Jul 31, 2023
1 parent 9e71feb commit 1957403
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 8 deletions.
9 changes: 6 additions & 3 deletions src/atoss_cli/atoss.clj
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@

(def update-btn {:css ".z-toolbarbutton:nth-of-type(1)"})
(def date-input {:css ".z-datebox-input"})
(def timepair-table {:css "div.slick-pane.slick-pane-top.slick-pane-left > div.slick-viewport.slick-viewport-top.slick-viewport-left"})
(def time-pair-row {:css "div.slick-row"})
(def add-time-pair-btn {:css "ul.z-menupopup-content > li.z-menuitem > a.z-menuitem-content:first-of-type"})

(defprotocol TimeSheetDay
(fmt-row [day]))
Expand Down Expand Up @@ -75,9 +78,9 @@

(defn setup-driver
"Create a default driver instance to be used for interacting with ATOSS. Headless by default."
([] (setup-driver true))
([headless?]
(let [driver (api/chrome {:headless headless?})]
([] (setup-driver {:headless true}))
([opts]
(let [driver (api/chrome opts)]
(api/set-window-size driver 1200 800)
driver)))

Expand Down
21 changes: 16 additions & 5 deletions src/atoss_cli/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,21 @@
(:import (java.util Collection))
(:gen-class))


(def mac-chrome-path "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome")

(defn -maybe-inject-mac-chrome-path
"Inject the path to the Chrome binary on macOS if the current OS is macOS."
[opts]
(let [os-name (System/getProperty "os.name")]
(if (re-find #"Mac OS X" os-name)
(assoc opts :path-browser mac-chrome-path)
opts)))

(defn log-time
"Log a time pair for a given date."
[{opts :options}]
(let [driver (atoss/setup-driver)
(let [driver (atoss/setup-driver (-maybe-inject-mac-chrome-path {:headless true}))
config (config/load-in)
{date :date} opts
session-opts (merge opts config)]
Expand All @@ -31,11 +42,11 @@
(green "Logged time for date: " date))
(shutdown-agents))

(catch Exception e
(catch Exception e
(-> e
(.getMessage)
(red)
(println))
(.getMessage)
(red)
(println))
(atoss/end driver)))))

(defn web
Expand Down

0 comments on commit 1957403

Please sign in to comment.