Skip to content

Commit

Permalink
Allow to use standard GNU help flag
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniils Petrovs committed Sep 23, 2021
1 parent 266a9ea commit 060798c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ If you are unsure about available day codes, you can always check ATOSS manually
You can always view the available arguments by typing

```bash
atoss-cli help
atoss-cli --help
```

### Requirements
Expand Down
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
(defproject atoss-cli "0.1.1-SNAPSHOT"
(defproject atoss-cli "0.1.2-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
17 changes: 9 additions & 8 deletions src/atoss_cli/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
"Entrypoint module for the ATOSS CLI."
(:require [clojure.tools.cli :refer [parse-opts]]
[atoss-cli.atoss :as atoss])
(:import (java.util Date) [java.text SimpleDateFormat])
(:import (java.util Date Collection) [java.text SimpleDateFormat])
(:gen-class))

(def desc "ATOSS CLI by Platogo Interactive Entertainment Gmbh.
Authors: Daniils Petrovs")
(def desc "ATOSS CLI by Platogo Interactive Entertainment Gmbh.")

(def today-date (.format
(java.text.SimpleDateFormat. "dd.MM.yyyy")
(new java.util.Date)))
(SimpleDateFormat. "dd.MM.yyyy")
(new Date)))

(def cli-options
;; An option with a required argument
Expand All @@ -29,7 +28,8 @@ Authors: Daniils Petrovs")
:default 0
:update-fn inc]
;; A boolean option defaulting to nil
["-h" "--help"]])
["-h" "--help" "Show this help printout."
:default false]])

(defn log-time
"Perform time logging with the given options."
Expand All @@ -48,9 +48,10 @@ Authors: Daniils Petrovs")

(defn -main [& args]
(println desc)
(let [{^java.util.Collection arguments :arguments
(let [{^Collection arguments :arguments
summary :summary,
options :options,
:as opts} (parse-opts args cli-options)]
(if (.contains arguments "help")
(if (or (.contains arguments "help") (options :help))
(println summary)
(log-time opts))))

0 comments on commit 060798c

Please sign in to comment.