From 060798c9434a1c7a691f577a0cf24f19752e9053 Mon Sep 17 00:00:00 2001 From: Daniils Petrovs Date: Thu, 23 Sep 2021 11:06:00 +0200 Subject: [PATCH] Allow to use standard GNU help flag --- README.md | 2 +- project.clj | 2 +- src/atoss_cli/core.clj | 17 +++++++++-------- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 6957d56..dd5cbdc 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/project.clj b/project.clj index ecf2d80..b7ce083 100644 --- a/project.clj +++ b/project.clj @@ -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" diff --git a/src/atoss_cli/core.clj b/src/atoss_cli/core.clj index d724e2f..05e7c4b 100644 --- a/src/atoss_cli/core.clj +++ b/src/atoss_cli/core.clj @@ -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 @@ -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." @@ -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))))