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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
|
# File 'lib/six/arma/builder/options.rb', line 10
def parse_options
todo, general_todo, second_todo = [], [], []
options = Hash.new
options[:verbose] = true
OptionParser.new do |opts|
$0[/.*\/(.*)/]
opts.banner = "Usage: #{$1} [config.yml] [options]"
opts.on("-v", "--[no-]verbose", "Run verbosely") do |v|
options[:verbose] = v
end
opts.on("-i", "--install", "Installs the mods, unless already installed") do |bool|
todo << :install if bool
end
opts.on("-d", "--uninstall", "Uninstalls the mods, unless not installed") do |bool|
todo << :uninstall if bool
end
opts.on("-u", "--update", "Updates each mod to latest version") do |bool|
todo << :update if bool
end
opts.on("-r", "--reset", "Resets the modfolders to latest commit status. All modifications lost") do |bool|
todo << :reset if bool
end
opts.on("-z", "--userconfig", "Processes the userconfigs of each mod. Makes backups of previous files") do |bool|
todo << :userconfig if bool
end
opts.on("-l", "--changelog", "Display Changelog after update") do |bool|
second_todo << :changelog if bool
end
opts.on("-c", "--cleanup", "Cleans up the modfolders git repositories") do |bool|
second_todo << :cleanup if bool
end
opts.on("-s", "--createshortcut", "Creates shortcut to run the game with the mods, in installation folder") do |bool|
general_todo << :createshortcut if bool
end
opts.on("-k", "--createdesktopshortcut", "Creates shortcut to run the game with the mods, on the desktop") do |bool|
general_todo << :createdesktopshortcut if bool
end
opts.on("-g", "--startgame", "Starts the game with #{@config[:armaparams]} -mod=#{@mods}") do |bool|
general_todo << :startgame if bool
end
opts.on("-w", "--wait", "Waits at the end for user pressing ENTER") do |bool|
options[:wait] = bool
end
opts.on("-f", "--force", "Forces to run tasks even though no changes were detected") do |bool|
options[:force] = bool
end
opts.on("--mods S", String, "Additional Mods") do |s|
options[:mods] = s
end
opts.on("--armapath S", String, "Destination folder") do |s|
options[:armapath] = s
end
opts.on("--gitpath S", String, "Git binary") do |s|
options[:gitpath] = s
end
end.parse!
default = if (todo + second_todo + general_todo).size > 0
false
else
true
end
@todo = if todo.size > 0
todo
else
log.info "No parameters given, running the default"
options[:wait] = true
if default
@config[:defaultactions]
else
[]
end
end
@general_todo = if general_todo.size > 0
general_todo
else
if default
@config[:defaultgeneralactions]
else
[]
end
end
@second_todo = if second_todo.size > 0
second_todo
else
if default
@config[:defaultsecondactions]
else
[]
end
end
@config = @config.merge(options)
end
|