dthree / vorpal

Node's framework for interactive CLIs
http://vorpal.js.org
MIT License
5.64k stars 280 forks source link

how to get vorpal argument as an array #330

Open zelaxo opened 5 years ago

zelaxo commented 5 years ago

Vorpal arguments are returned as a string. How to get them as it is, ie. get an object array as an object array.

Please refer here for a broader explanation : https://stackoverflow.com/q/53297013/8619824

b4dnewz commented 5 years ago

@zaygozi it should be command <arg...> according to the documentation, are called variadic arguments

zelaxo commented 5 years ago

@b4dnewz But variadic arguments return an array of strings. So if the input is {name:'anon',time:9}, this is returned as a type string & not an object. The only way I found to resolve this was to pass the input as a json object {"name":"arjun","time":9} & then use JSON.parse to retrieve the object from the string.