pertsevds

pertsevds

Command line arguments parsing problem / How can i pass 2 arguments for an option?

script.exs source:

IO.inspect System.argv

running with:

elixir script.exs --options=25,26

Environment

  • Elixir & Erlang/OTP versions (elixir --version):
    Erlang/OTP 21 [erts-10.3] [64-bit] [smp:4:4] [ds:4:4:10] [async-threads:1]
    Elixir 1.11.1 (compiled with Erlang/OTP 21)

  • Operating system: Windows 10

Current behavior

Output:
[“–options”, “25”, “26”]

Expected behavior

Output:
[“–options”, “25,26”]

So, when i try to

OptionParser.parse(System.argv, strict: [options: :string])

it gives me only [options: “25”] and i want [options: “25,26”].
Is this a normal behavior?

Marked As Solved

pertsevds

pertsevds

Experimented a little and found a source of the problem - PowerShell.

  1. Through cmd.exe:

elixir ttt.exs --options 25,26
argv: [“–options”, “25”, “26”]
parsed: {[options: “25”], [“26”], }
but this works:
elixir ttt.exs --options “25,26”
argv: [“–options”, “25,26”]
parsed: {[options: “25,26”], , }

  1. Through PowerShell which is default on Win10:

elixir ttt.exs --options 25,26
argv: [“–options”, “25”, “26”]
parsed: {[options: “25”], [“26”], }
and this does not work either:
elixir ttt.exs --options “25,26”
argv: [“–options”, “25”, “26”]
parsed: {[options: “25”], [“26”], }

Where Next?

Popular in Questions Top

itssasanka
Hi all, Trying to get some more clarity over utc_datetime and naive_datetime for Ecto: https://hexdocs.pm/ecto/Ecto.Schema.html#module-...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
New
Kagamiiiii
Student & New to elixir. Nice language. I want to convert a english character, e.g. “a”, which is stored in a variable, to it’s asci...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
belgoros
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New

Other popular topics Top

peerreynders
Manning 2016 Halloween weekend sale via Deal of the Day Friday, October 28 - Half off all MEAPs - code WM102816LT Saturday, October 29 ...
326 29600 154
New
dotdotdotPaul
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
lastday4you
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Qqwy
Original source of discussion: This topic on the Pragmatic Programmers' Functional Web Development with Elixir, OTP, and Phoenix forum. ...
New
AstonJ
by Lance Halvorsen Elixir and Phoenix are generating tremendous excitement as an unbeatable platform for building modern web application...
460 27162 124
New
vrod
I am using the Starship cross-shell prompt – it seems pretty nice, but I get some errors: [WARN] - (starship::utils): Executing command ...
New

We're in Beta

About us Mission Statement