Skip to content

Commit

Permalink
Merge pull request #10 from axrs/cci-8
Browse files Browse the repository at this point in the history
cci-8
  • Loading branch information
axrs committed Jan 10, 2020
2 parents b582a99 + 043b172 commit 0575515
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 8 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# 0.3.2

Fixed:
* Intermittent crash caused by attempting to show a notification without a subject

Misc:
* Updated `backpack` to `4.2.0`

# 0.3.1

Fixed:
Expand Down
4 changes: 2 additions & 2 deletions project.clj
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
(defproject io.axrs.cli/circle-ci "0.3.1"
(defproject io.axrs.cli/circle-ci "0.3.2"
:description "A CircleCI CLI"
:license "Eclipse Public License - v 2.0"
:url "https://github.com/axrs/circle-ci"
:dependencies [[org.clojure/clojure "1.10.1"]
[cli-matic "0.3.6" :exclusions [org.clojure/clojure]]
[clj-time "0.15.2"]
[com.taoensso/encore "2.117.0" :exclusions [org.clojure/clojure]]
[io.jesi/backpack "4.0.1" :exclusions [clojure-complete
[io.jesi/backpack "4.2.0" :exclusions [clojure-complete
com.lucasbradstreet/cljs-uuid-utils
medley
nrepl
Expand Down
5 changes: 3 additions & 2 deletions src/io/axrs/cli/circle_ci/core.clj
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@
(filter-by-params params))]
(when notify?
(doseq [{:keys [reponame branch job-name run-time build-url subject]} (filter (comp (bp/p= "failed") :status) results)]
(when-not (contains? @notified build-url)
(when (and subject
(not (contains? @notified build-url)))
(notification/send {:message subject
:subtitle (str job-name " failed (" run-time ")")
:url build-url
Expand All @@ -140,7 +141,7 @@
(defonce ^:private cli-config
{:app {:command "circle-ci"
:description "A CircleCI CLI"
:version "0.3.1"}
:version "0.3.2"}
:commands [
{:command "cols"
:description ["Prints a list of columns available for use in tabular outputs"]
Expand Down
21 changes: 17 additions & 4 deletions src/io/axrs/cli_tools/notifications.clj
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
(ns io.axrs.cli-tools.notifications
(:refer-clojure :exclude [send])
(:require [clojure.java.shell :as sh]))
(:require
[io.jesi.backpack.macros :refer [def-]]
[clojure.java.shell :as sh]
[clojure.string :as string]))

(defn- clean-exit? [{:keys [exit]}]
(zero? exit))
Expand All @@ -25,7 +28,17 @@
(clean-exit? (sh/sh "osascript" "-e" (str "display notification \"" message "\" with title \"" title "\""
(when subtitle (str " subtitle \"" subtitle "\"")))))))

(def- non-blank? (complement string/blank?))

(defn- optional-non-empty-string [s]
(or (nil? s)
(non-blank? s)))

(defn send [{:keys [message title subtitle url] :as notification}]
(or
(terminal-notifier notification)
(osascript notification)))
{:pre [(non-blank? message)
(non-blank? title)
(optional-non-empty-string subtitle)
(optional-non-empty-string url)]
(or
(terminal-notifier notification)
(osascript notification))})

0 comments on commit 0575515

Please sign in to comment.