erlware / relx

Sane, simple release creation for Erlang
http://erlware.github.io/relx
Apache License 2.0
697 stars 232 forks source link

How to call an rpc with multiple arguments? #748

Closed kektobiologist closed 4 years ago

kektobiologist commented 5 years ago

eg.

${RELX_TOOL} rpc string concat "a" "b"

This currently calls it with a single argument ["a","b"] instead of two arguments. Is there a way to call a function with multiple arguments? I couldn't find any documentation related to this. #480 seemed to address the issue but it's not merged.

ferd commented 5 years ago

I can't recall of a workaround for it. As you said, the patch in #480 seemed to address it, but it appears it also contained a bunch of other things that might not have been desirable. I don't think there would be a huge problem adding support for consult-style RPC arguments, although I'd be worried of breaking existing toolchains of tools deployed in the wild.

ferd commented 5 years ago

Ah it turns out by reading the source code that there already is added support for it, and gave it a new name. Just use rpcterms instead of rpc: https://github.com/erlware/relx/blob/master/priv/templates/nodetool#L47-L55

kektobiologist commented 5 years ago

I've tried rpcterms, it gives the same result. Can you share a working example? The only example in the source code calls a function with no arguments

raoneeraj commented 5 years ago

I am also facing the same issue while using rpcterms to pass multiple arguments to a function. can someone explain how to use rpcterms in case if function requires multiple arguments.

ferd commented 5 years ago

Yeah I'm trying it again and it seems like the rpcterms feature is buggy. It handles single arguments almost fine (globs spaces):

_build/default/rel/chk/bin/chk rpcterms erlang display '[this, is, a, <<"term">>, "Hello world~n!"]. '

displays [this,is,a,<<"term">>,"Helloworld~n!"], but it won't work with multiple arguments easy. I'm guessing this stuff needs to be reworked.

tsloughter commented 4 years ago

This has been resolved in master and will be in the upcoming release. rpcterms has been removed and replaced with just the rpc command with an improved way of calling it.

To call foo:bar(1,2,3):

bin/<release_script> rpc foo bar "[1,2,3]."