Regupathy
Regupathy

Reputation: 83

How to set multiple command line argument for single Flag in erl

In Erlang,

we can pass multiple input to the Erlang system by command line arguments.

erl -sname name1 -setcookie abcd

how to pass multiple values for a single Flag?

Upvotes: 1

Views: 389

Answers (2)

ketam
ketam

Reputation: 11

You can read more about processing command line arguments in the Erlang doc, here.

Upvotes: 0

Regupathy
Regupathy

Reputation: 83

We can able to sent multiple Values to a single Flag.

Values are differentiated by Space character

erl -key1 val1 val2 val3
Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false]

Eshell V6.3  (abort with ^G)
1> init:get_argument(key1).
{ok,[["val1","val2","val3"]]}

You can pass multiple Key Values pairs like

erl -key1 val1 val2 val3 -key2 val11 val12 val13
Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false]

Eshell V6.3  (abort with ^G)
1> init:get_argument(key2).
{ok,[["val11","val12","val13"]]}
2> init:get_argument(key1).
{ok,[["val1","val2","val3"]]}

If you pass key more than one time you get the values as like

 erl -key1 val1 val2 val3 -key1 val11 val12 val13
 Erlang/OTP 17 [erts-6.3] [source] [64-bit] [smp:2:2] [async-threads:10] [kernel-poll:false]

 Eshell V6.3  (abort with ^G)
 1> init:get_argument(key1).
 {ok,[["val1","val2","val3"],["val11","val12","val13"]]}
 2>

Upvotes: 1

Related Questions