5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/digipolitan-apps-tools/argv.rb', line 5
def self.parse()
map = {}
count = ARGV.count
i = 0
while i < count
arg = ARGV[i]
if arg.index("-") == 0
key = arg
data = []
i += 1
while i < count
arg = ARGV[i]
if arg.index("-") != 0
data.push(arg)
i += 1
else
i -= 1
break
end
end
data_count = data.count
if data_count > 1
map[key] = data
elsif data_count > 0
map[key] = data[0]
else
map[key] = true
end
end
i += 1
end
return map
end
|