Skip to content

Commit

Permalink
Exit with a non-zero code, if a page is not found
Browse files Browse the repository at this point in the history
  • Loading branch information
hisaitami committed Nov 4, 2023
1 parent f3e34d7 commit 1affb28
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ Comply with [minium specifications](https://github.com/tldr-pages/tldr/wiki/Mini
- [x] Page names MAY contain mixed capitalization, and such page names MUST be transparently lowercased. For example, the page name eyeD3 becomes eyed3.
- [x] Clients MUST default to displaying the page associated with the platform on which the client is running.
- [x] If a page is not available for the host platform, clients MUST fall back to the special common platform.
- [ ] If a page is not found, Clients that have control over their exit code on the command line (i.e. clients that provide a CLI) MUST exit with a non-zero exit code in addition to showing the above message.
- [x] If a page is not found, Clients that have control over their exit code on the command line (i.e. clients that provide a CLI) MUST exit with a non-zero exit code in addition to showing the above message.


12 changes: 6 additions & 6 deletions tldr.cljs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@

(def cache-date (io/file (:home env) tldr-home "date"))

(defn die [& args]
(binding [*print-fn* *print-err-fn*]
(println (apply str args)))
(exit 1))

(defn cache-path
([]
(io/file (:home env) tldr-home pages-dir))
Expand Down Expand Up @@ -69,7 +74,7 @@

(defn fetch [cache]
(if (io/exists? cache) (slurp cache)
"This page doesn't exist yet!"))
(die "This page doesn't exist yet!")))

(defn display
([page]
Expand All @@ -84,11 +89,6 @@
(let [path (cache-path platform)]
(rand-nth (io/list-files path))))

(defn die [& args]
(binding [*print-fn* *print-err-fn*]
(println (apply str args)))
(exit 1))

(defn mkdtemp [template]
(let [{:keys [out err]} (sh "mktemp" "-d" template)]
(or (empty? err) (die "Error: Creating Directory:" template))
Expand Down

0 comments on commit 1affb28

Please sign in to comment.