This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-03-25
Channels
- # aws (1)
- # beginners (60)
- # boot (12)
- # cider (7)
- # cljs-dev (8)
- # cljsrn (24)
- # clojure (169)
- # clojure-nl (1)
- # clojure-russia (3)
- # clojure-spec (15)
- # clojure-switzerland (1)
- # clojure-uk (24)
- # clojurescript (120)
- # core-async (9)
- # datomic (3)
- # emacs (2)
- # gsoc (3)
- # klipse (2)
- # leiningen (4)
- # numerical-computing (13)
- # off-topic (95)
- # om (7)
- # onyx (1)
- # powderkeg (2)
- # protorepl (2)
- # re-frame (6)
- # reagent (58)
- # ring-swagger (1)
- # rum (28)
- # untangled (42)
- # vim (6)
Tenuously related to REST APIs but has anyone else played with GraphQL? I came across https://github.com/walmartlabs/lacinia and it’s rekindled my interest
Bore da
@otfrom I do but not much non permanent
@davesnowdon we've been using graphql-clj in a preliminary evaluation on some projects. Definitely changes the way you build apis.
I’ve got a clojure cli app that exits with a System/exit
that does not play nice with repl.
Have -main
call a function to do its work. Call that from the REPL.
Your -main
can use the result of that function call to pick the value used in the System/exit
call. This is one of those "boundary cases" where you should separate the system "side-effect" (in this case exiting the JVM) from the functional work that you code needs to perform. @mattford
Either put it in a function or just evaluate those sub-forms in the REPL.
(defn -main [& args]
(let [{:keys [options arguments errors summary]} (parse-opts args cli-options)]
;; Handle help and error conditions
(cond
(:help options) (exit 0 (usage summary))
(not= (count arguments) 1) (exit 1 (usage summary))
errors (exit 1 (error-msg errors)))
;; Execute program with options
(case (first arguments)
"start" (server/start! options)
"stop" (server/stop! options)
"status" (server/status! options)
(exit 1 (usage summary)))))
Yeah but GitHub READMEs are rarely the paragon of best practices, I'm afraid.
So that's tools.cli
... and parsing is already separate so what you would test here is the result of calling parse-opts
, that you get the errors
you expect. I guess I'm not quite sure what you're trying to do by calling -main
from the REPL...
I guess I could update the tools.cli
README to use an example that did not just call System/exit
, since I maintain that library these days 🙂