-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move CLI functionality into separate namespace
- Loading branch information
Daniils Petrovs
committed
Oct 1, 2021
1 parent
c3d6e42
commit 146b878
Showing
2 changed files
with
54 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
(ns atoss-cli.cli | ||
(:require [atoss-cli.atoss :refer [valid-day-codes]]) | ||
(:import (java.text SimpleDateFormat) | ||
(java.util Date))) | ||
|
||
(def today-date (.format | ||
(SimpleDateFormat. "dd.MM.yyyy") | ||
(new Date))) | ||
|
||
(def desc "ATOSS CLI by Platogo Interactive Entertainment Gmbh. | ||
Work seamlessly with ATOSS time sheets.") | ||
|
||
(def help-header " | ||
\033[1;37mUSAGE\u001b[0m | ||
atoss-cli <command> [args] | ||
\033[1;37mCOMMANDS\u001b[0m | ||
log: Log time pair for today or a specific date | ||
view: View month overview of logged time") | ||
|
||
(def options | ||
;; An option with a required argument | ||
[["-d" "--date DATE" "Date in the format DD.MM.YYYY" | ||
:default today-date] ;; FIXME: Add validation | ||
["-c" "--day-code CODE" "Valid ATOSS day code (e.g. wh for WFH) can also be left blank." | ||
:default nil | ||
:validate [#(contains? valid-day-codes %) "Must be a valid ATOSS time code."]] | ||
["-s" "--start-time TIME" "Work start time in the format HH:MM" | ||
:default "9:00"] | ||
["-e" "--end-time TIME" "Work end time in the format HH:MM" | ||
:default "17:00"] | ||
;; A non-idempotent option (:default is applied first) | ||
["-v" nil "Verbosity level" | ||
:id :verbosity | ||
:default 0 | ||
:update-fn inc] | ||
;; A boolean option defaulting to nil | ||
["-h" "--help" "Show this help printout." | ||
:default false]]) | ||
|
||
(defn print-help | ||
[args-summary] | ||
(print desc) | ||
(newline) | ||
(print help-header) | ||
(newline) | ||
(newline) | ||
(print args-summary)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters