l3nz / cli-matic

Compact, hands-free [sub]command line parsing library for Clojure.
Eclipse Public License 2.0
361 stars 29 forks source link

Add YAML support (optional like json) #30

Closed jwhitlark closed 6 years ago

jwhitlark commented 6 years ago

I do a lot of work with Kubernetes stuff, and YAML is the preferred format.

I'm working on this in my fork; I'll open a pull request when it's ready.

l3nz commented 6 years ago

Good! just a couple of notes:

Thanks!

jwhitlark commented 6 years ago

So I got it working, but sadly the lib I used has reflection in it, so breaks graal, which is a no-go in my opinion. I'll try and get back to it next week, but if anyone else wants to take a stab, here's my branch with all the above requirements met: https://github.com/jwhitlark/cli-matic/tree/yaml-support

l3nz commented 6 years ago

Do you get a specific error in GraalVM? I think that the approach we use for detecting libraries is scalable (in a sense) so I would not mind testing a couple of libraries in sequence - maybe the first being clj-yaml and then a clojure-only implementation. Or rolling something up based on Jackson - just reading should not be hard.

jwhitlark commented 6 years ago

I think it's just a transitive dependency, but didn't have any more time yesterday. I've not check alternate YAML libs, but I agree, just reading should be pretty easy. The run below is an empty project, with a single call to io.forward/yaml - yaml.core/parse-string.

[jw@xps intro]$ ./intro-1.0.0-SNAPSHOT-standalone
Started                                                                                                                                                       Exception in thread "main" java.lang.reflect.InvocationTargetException
        at java.lang.Throwable.<init>(Throwable.java:310)                                                                                                             at java.lang.Exception.<init>(Exception.java:102)
        at java.lang.ReflectiveOperationException.<init>(ReflectiveOperationException.java:89)                                                                        at java.lang.reflect.InvocationTargetException.<init>(InvocationTargetException.java:72)                                                                      at com.oracle.svm.reflect.proxies.Proxy_1_intro_main.invoke(Unknown Source)                                                                                   at java.lang.reflect.Method.invoke(Method.java:498)
        at com.oracle.svm.core.JavaMainWrapper.run(JavaMainWrapper.java:173)
Caused by: java.lang.ClassNotFoundException: org.yaml.snakeyaml.Yaml
        at java.lang.Throwable.<init>(Throwable.java:287)
        at java.lang.Exception.<init>(Exception.java:84)
        at java.lang.ReflectiveOperationException.<init>(ReflectiveOperationException.java:75)                                                                        at java.lang.ClassNotFoundException.<init>(ClassNotFoundException.java:82)                                                                                    at com.oracle.svm.core.hub.ClassForNameSupport.forName(ClassForNameSupport.java:51)                                                                           at com.oracle.svm.core.hub.DynamicHub.forName(DynamicHub.java:911)                                                                                            at clojure.lang.RT.classForName(RT.java:2204)                                                                                                                 at clojure.lang.RT.classForName(RT.java:2213)                                                                                                                 at yaml.reader$parse_string.invokeStatic(reader.clj:71)                                                                                                       at yaml.reader$parse_string.doInvoke(reader.clj:57)
        at clojure.lang.RestFn.invoke(RestFn.java:410)
        at org.cloudnativeclojure.intro$_main.invokeStatic(intro.clj:7)                                                                                               at org.cloudnativeclojure.intro$_main.doInvoke(intro.clj:5)
        at clojure.lang.RestFn.invoke(RestFn.java:397)
        at clojure.lang.AFn.applyToHelper(AFn.java:152)
        at clojure.lang.RestFn.applyTo(RestFn.java:132)
        at org.cloudnativeclojure.intro.main(Unknown Source)
        ... 3 more
jwhitlark commented 6 years ago

So I added optional Yaml support, but if you use it, it won't work with graal. It's a step in the right direction, though. https://github.com/l3nz/cli-matic/pull/31

l3nz commented 6 years ago

I merged and published the new version.

jwhitlark commented 6 years ago

Thanks!

On Tue, Jul 31, 2018 at 11:24 PM, lenz notifications@github.com wrote:

Closed #30 https://github.com/l3nz/cli-matic/issues/30.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/l3nz/cli-matic/issues/30#event-1764399151, or mute the thread https://github.com/notifications/unsubscribe-auth/AADovONVWq2fUrvDU2Moj0p_pbAifyzjks5uMUmigaJpZM4VZF4Y .