Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make run consistent with submit when parsing option arguments #189

Merged
merged 1 commit into from
Sep 28, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions jvm/src/streamparse/commands/run.clj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
(:require [clojure.string :as string]
[streamparse.cli :refer [cli]]
[clojure.stacktrace :refer [print-stack-trace]]
[clojure.core :refer [fn?]])
[clojure.core :refer [fn?]]
[clojure.data.json :as json])
(:use [backtype.storm clojure config])
(:import [backtype.storm LocalCluster])
(:gen-class))
Expand Down Expand Up @@ -40,10 +41,19 @@
""]
(string/join \newline)))

(defn smart-read-str [val]
"Read JSON string and don't convert git hashes to numbers"
;; issue with literals that start with digits, but contain letters
(if (not= (re-find #"\d+[A-Za-z]" val) nil)
val
(try
(json/read-str val)
(catch Exception e val))))

(defn -parse-topo-option [val-str]
"Parse topology --option in option.key=val form."
(let [[key val] (string/split val-str #"=")
parsed-val (read-string val)]
parsed-val (smart-read-str val)]
{key parsed-val}))

(defn -assoc-topo-option [previous key val]
Expand Down