Fork me on GitHub
#shadow-cljs
<
2018-04-25
>
genRaiy11:04:59

I am trying …. for a CLI app to provide options & usage

genRaiy11:04:32

there are two excellent node libs command-line-args and command-line-usage

genRaiy11:04:49

command line-args integrates very easily

genRaiy11:04:06

but am having some trouble with command-line-usage

genRaiy11:04:22

has anyone seen this before?

thheller11:04:09

@raymcdermott are you not using :target :node-script?

genRaiy11:04:45

I am using that

genRaiy11:04:44

standard stuff afaik

thheller11:04:56

right, sorry I was confused for a sec.

thheller11:04:08

this is using the code directly from node_modules without any processing

thheller11:04:14

not really sure why it would fail

thheller11:04:36

do you maybe call it with nil?

genRaiy11:04:04

I don’t think so …. checking

thheller11:04:26

you can try running node package/main.js --inspect-brk and then turn on pause on exceptions

thheller11:04:48

then check the stack to see what value was used to call the failing function

genRaiy11:04:33

UNKNOWN_OPTION: Unknown option: --inspect-brk

thheller11:04:51

node --inspect-brk package/main.js ?

thheller11:04:37

should show the node process then

genRaiy11:04:25

it gives an error on domain.js

thheller11:04:22

no idea. doesn't seem to be the exception you are looking for. does it work if you just let it run again?

genRaiy11:04:15

no, then same error on bootstrap_node.js

genRaiy11:04:32

then module.js

genRaiy11:04:56

then internal/module.js

genRaiy11:04:13

then the error I posted

thheller11:04:16

that is misleading, the error occurs while your code is LOADING not while it is executing

thheller11:04:31

probably because you run the function directly

genRaiy11:04:43

oh yes, I do that

thheller11:04:29

if you run it inside vouch-admin-cli.main/main the exception might be clearer

genRaiy11:04:56

it runs inside main

genRaiy11:04:18

sorry, misunderstood what you meant there

thheller11:04:47

oh right sorry.

thheller11:04:02

ok bascially what happens is that shadow-cljs appends a file that contains (vouch-admin-cli.main/main ...)

thheller11:04:10

this causes your main function to run

thheller11:04:14

and your main function throws

thheller11:04:26

because shadow-cljs was still loading the file it is one the stack

thheller11:04:33

but it has nothing to do with shadow-cljs

genRaiy11:04:05

so is it the transitive dep?

thheller11:04:19

no. it just seems to confuse the debugger

thheller11:04:47

you should get to node_modules/command-line-usage/lib/chalk-format.js:8:13 in the debugger

thheller11:04:04

don't know why it would show module.js and the other stuff

genRaiy11:04:56

it’s giving str = undefined

genRaiy11:04:11

which is the arg being passed it

thheller11:04:14

chrome should show the stack

thheller11:04:27

just go up the stack until you see how it got to be undefined

thheller12:04:48

npx shadow-cljs node-repl

thheller12:04:50

(ns foo.bar (:require ["command-line-usage" :as x]))

thheller12:04:58

(x (clj->js [{:header  "My CLI"
              :content "Manage your environment"}
             {:header     :Options
              :optionList [{:name        "create-xxxx"
                            :alias       :c
                            :typeLabel   "{underline name}"
                            :description "Create xxxx with that name"}
                           {:name        "help"
                            :alias       :h
                            :description "Print this usage guide."}]}]))

thheller12:04:11

"
 My CLI\r
 \r
   Manage your environment \r
 
 Options\r
 \r
   -c, --create-xxxx name   Create xxxx with that name \r
   -h, --help               Print this usage guide.    \r
 "

genRaiy12:04:39

I have some entries without a :description key

genRaiy12:04:54

and that breaks it !

genRaiy12:04:00

if only JS had spec

genRaiy12:04:14

thanks vm for your help

genRaiy12:04:25

would have wasted a shit ton more time

genRaiy12:04:34

and I know I can debug with chrome now 🙂

👍 4
genRaiy12:04:57

I’m still loving those libs though

grav13:04:02

Is it possible to specify dependencies directly from github?

troglotit15:04:04

I think what OP meant was if it's possible with regards to shadow-cljs not deps.edn

Ivan Fedorov14:04:05

Hi Channel! Is there an tutorial entry on how to combine server clj run by leiningen with shadow-cljs? In a manner of how figwheel does that I can do a tutorial entry for that, if you explain. p.s. the tool is awesome, great thanks to the author and conrtibutors UPD: found a proper example, thanks

thheller19:04:12

@grav it is possible if you use deps.edn. directly from shadow-cljs no

👍 4
donmullen21:04:04

@thheller even though shadow-cljs didn’t make top two to be funded by clojurists together - good to see it come in a strong #4 - good exposure. Perhaps next round! https://www.clojuriststogether.org/news/q2-2018-funding-announcement/

🎉 12
danielcompton21:04:02

Yeah it was a good application and we would have liked to fund it if we had more money

👍 44