Skip to content

Commit

Permalink
Add new view command to show month overview
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniils Petrovs committed Sep 30, 2021
1 parent a23940b commit 0bae7c3
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 6 deletions.
6 changes: 4 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject atoss-cli "0.1.3-SNAPSHOT"
(defproject atoss-cli "0.2.0-SNAPSHOT"
:description "A CLI tool for interacting with ATOSS time sheets"
:url "https://github.com/platogo/atoss-cli"
:license {:name "EPL-2.0 OR GPL-2.0-or-later WITH Classpath-exception-2.0"
Expand Down Expand Up @@ -27,6 +27,8 @@
:profiles {:uberjar {:aot :all
:native-image {:jvm-opts ["-Dclojure.compiler.direct-linking=true"]}}}
:plugins [[lein-cljfmt "0.8.0"]
[cider/cider-nrepl "0.26.0"]
[io.taylorwood/lein-native-image "0.3.1"]]
:jvm-opts ["-Dclojure.compiler.direct-linking=true"]
:repl-options {:init-ns atoss-cli.core})
:repl-options {:init-ns atoss-cli.core
:init (do (use 'etaoin.api) (require '[etaoin.keys :as keys]))})
2 changes: 1 addition & 1 deletion src/atoss_cli/atoss.clj
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@
driver))

(defn login
"Perform login into ATOSS dashboard using provided ATOSS credentials."
"Login into ATOSS dashboard using provided credentials."
[driver {user :username pass :password}]
(println "Logging into ATOSS with user: " user)
(doto driver
Expand Down
22 changes: 19 additions & 3 deletions src/atoss_cli/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Work seamlessly with ATOSS time sheets.")
(print args-summary))

(defn log-time
"Perform time logging with the given options."
"Log a time pair for a given day."
[{opts :options}]
(let [driver (atoss/setup-driver)
creds (atoss/creds-from-dotfile)
Expand All @@ -63,13 +63,29 @@ Work seamlessly with ATOSS time sheets.")
(atoss/end))
(println "Logged time")))

(defn show-month-overview
"Display the current month overview in the terminal."
[]
(let [driver (atoss/setup-driver)
creds (atoss/creds-from-dotfile)]
(doto driver
(atoss/login creds)
(atoss/nav-to-month-overview))
(let [days (atoss/parse-month-table-rows driver)]
(println "\033[1;37mMonth overview:")
(newline)
(doseq [day days]
(-> day
(atoss/fmt-row)
(println))))))

(defn -main [& args]
(println desc)
(let [{^Collection arguments :arguments
summary :summary,
options :options,
:as opts} (parse-opts args cli-options)]
(cond
(options :help) (-print-help summary)
(.contains arguments "log") (log-time opts)
(= (first arguments) "view") (show-month-overview)
(= (first arguments) "log") (log-time opts)
:else (-print-help summary))))

0 comments on commit 0bae7c3

Please sign in to comment.