u3d 0.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +2 -0
  3. data/.licenses.json +19 -0
  4. data/.rspec +1 -0
  5. data/.rubocop.yml +43 -0
  6. data/Gemfile +5 -0
  7. data/Gemfile.lock +98 -0
  8. data/LICENSE +21 -0
  9. data/LICENSE.fastlane +22 -0
  10. data/LOG_RULES.md +170 -0
  11. data/README.md +72 -0
  12. data/Rakefile +28 -0
  13. data/TODO.md +15 -0
  14. data/build.sh +5 -0
  15. data/config/log_rules.json +230 -0
  16. data/examples/Example1/.gitignore +19 -0
  17. data/examples/Example1/Assets/Editor.meta +9 -0
  18. data/examples/Example1/Assets/Editor/EditorRun.cs +23 -0
  19. data/examples/Example1/Assets/Editor/EditorRun.cs.meta +12 -0
  20. data/examples/Example1/Assets/Editor/FileSystemUtil.cs +26 -0
  21. data/examples/Example1/Assets/Editor/FileSystemUtil.cs.meta +12 -0
  22. data/examples/Example1/Assets/Scene1.unity +264 -0
  23. data/examples/Example1/Assets/Scene1.unity.meta +8 -0
  24. data/examples/Example1/Gemfile +8 -0
  25. data/examples/Example1/Gemfile.lock +165 -0
  26. data/examples/Example1/ProjectSettings/AudioManager.asset +16 -0
  27. data/examples/Example1/ProjectSettings/ClusterInputManager.asset +6 -0
  28. data/examples/Example1/ProjectSettings/DynamicsManager.asset +18 -0
  29. data/examples/Example1/ProjectSettings/EditorBuildSettings.asset +7 -0
  30. data/examples/Example1/ProjectSettings/EditorSettings.asset +14 -0
  31. data/examples/Example1/ProjectSettings/GraphicsSettings.asset +61 -0
  32. data/examples/Example1/ProjectSettings/InputManager.asset +295 -0
  33. data/examples/Example1/ProjectSettings/NavMeshAreas.asset +89 -0
  34. data/examples/Example1/ProjectSettings/NetworkManager.asset +8 -0
  35. data/examples/Example1/ProjectSettings/Physics2DSettings.asset +35 -0
  36. data/examples/Example1/ProjectSettings/ProjectSettings.asset +591 -0
  37. data/examples/Example1/ProjectSettings/ProjectVersion.txt +1 -0
  38. data/examples/Example1/ProjectSettings/QualitySettings.asset +180 -0
  39. data/examples/Example1/ProjectSettings/TagManager.asset +43 -0
  40. data/examples/Example1/ProjectSettings/TimeManager.asset +9 -0
  41. data/examples/Example1/ProjectSettings/UnityConnectSettings.asset +32 -0
  42. data/examples/Example1/README.md +5 -0
  43. data/examples/Example1/Rakefile +5 -0
  44. data/examples/Example1/fastlane/Fastfile +4 -0
  45. data/examples/Example1/fastlane/Pluginfile +1 -0
  46. data/examples/Example1/run.sh +1 -0
  47. data/examples/Example2/.gitignore +20 -0
  48. data/examples/Example2/Assets/Editor.meta +9 -0
  49. data/examples/Example2/Assets/Editor/EditorRun.cs +33 -0
  50. data/examples/Example2/Assets/Editor/EditorRun.cs.meta +12 -0
  51. data/examples/Example2/Assets/Editor/PostprocessBuildPlayer.cs +92 -0
  52. data/examples/Example2/Assets/Editor/PostprocessBuildPlayer.cs.meta +8 -0
  53. data/examples/Example2/Assets/Editor/PostprocessBuildPlayer_log.sh +31 -0
  54. data/examples/Example2/Assets/Editor/PostprocessBuildPlayer_log.sh.meta +8 -0
  55. data/examples/Example2/Assets/Editor/SimpleBuildSetup.cs +20 -0
  56. data/examples/Example2/Assets/Editor/SimpleBuildSetup.cs.meta +12 -0
  57. data/examples/Example2/Assets/Scene.unity +278 -0
  58. data/examples/Example2/Assets/Scene.unity.meta +8 -0
  59. data/examples/Example2/Gemfile +8 -0
  60. data/examples/Example2/Gemfile.lock +165 -0
  61. data/examples/Example2/ProjectSettings/AudioManager.asset +17 -0
  62. data/examples/Example2/ProjectSettings/ClusterInputManager.asset +6 -0
  63. data/examples/Example2/ProjectSettings/DynamicsManager.asset +19 -0
  64. data/examples/Example2/ProjectSettings/EditorBuildSettings.asset +10 -0
  65. data/examples/Example2/ProjectSettings/EditorSettings.asset +14 -0
  66. data/examples/Example2/ProjectSettings/GraphicsSettings.asset +63 -0
  67. data/examples/Example2/ProjectSettings/InputManager.asset +295 -0
  68. data/examples/Example2/ProjectSettings/NavMeshAreas.asset +89 -0
  69. data/examples/Example2/ProjectSettings/NetworkManager.asset +8 -0
  70. data/examples/Example2/ProjectSettings/Physics2DSettings.asset +36 -0
  71. data/examples/Example2/ProjectSettings/ProjectSettings.asset +591 -0
  72. data/examples/Example2/ProjectSettings/ProjectVersion.txt +1 -0
  73. data/examples/Example2/ProjectSettings/QualitySettings.asset +193 -0
  74. data/examples/Example2/ProjectSettings/TagManager.asset +43 -0
  75. data/examples/Example2/ProjectSettings/TimeManager.asset +9 -0
  76. data/examples/Example2/ProjectSettings/UnityConnectSettings.asset +34 -0
  77. data/examples/Example2/README.md +10 -0
  78. data/examples/Example2/fastlane/Fastfile +4 -0
  79. data/examples/Example2/fastlane/Pluginfile +1 -0
  80. data/exe/u3d +7 -0
  81. data/fastlane-plugin-u3d/.gitignore +10 -0
  82. data/fastlane-plugin-u3d/.licenses.json +9 -0
  83. data/fastlane-plugin-u3d/.rspec +3 -0
  84. data/fastlane-plugin-u3d/.rubocop.yml +253 -0
  85. data/fastlane-plugin-u3d/.travis.yml +4 -0
  86. data/fastlane-plugin-u3d/Gemfile +6 -0
  87. data/fastlane-plugin-u3d/LICENSE +21 -0
  88. data/fastlane-plugin-u3d/README.md +52 -0
  89. data/fastlane-plugin-u3d/Rakefile +9 -0
  90. data/fastlane-plugin-u3d/circle.yml +9 -0
  91. data/fastlane-plugin-u3d/fastlane-plugin-u3d.gemspec +31 -0
  92. data/fastlane-plugin-u3d/fastlane/Fastfile +3 -0
  93. data/fastlane-plugin-u3d/fastlane/Pluginfile +1 -0
  94. data/fastlane-plugin-u3d/lib/fastlane/plugin/u3d.rb +38 -0
  95. data/fastlane-plugin-u3d/lib/fastlane/plugin/u3d/actions/u3d_action.rb +80 -0
  96. data/fastlane-plugin-u3d/lib/fastlane/plugin/u3d/helper/u3d_helper.rb +34 -0
  97. data/fastlane-plugin-u3d/lib/fastlane/plugin/u3d/version.rb +27 -0
  98. data/fastlane-plugin-u3d/spec/spec_helper.rb +32 -0
  99. data/lib/u3d.rb +33 -0
  100. data/lib/u3d/cache.rb +120 -0
  101. data/lib/u3d/commands.rb +307 -0
  102. data/lib/u3d/commands_generator.rb +163 -0
  103. data/lib/u3d/downloader.rb +363 -0
  104. data/lib/u3d/iniparser.rb +83 -0
  105. data/lib/u3d/installer.rb +445 -0
  106. data/lib/u3d/log_analyzer.rb +221 -0
  107. data/lib/u3d/unity_version_number.rb +71 -0
  108. data/lib/u3d/unity_versions.rb +207 -0
  109. data/lib/u3d/utils.rb +121 -0
  110. data/lib/u3d/version.rb +31 -0
  111. data/lib/u3d_core.rb +30 -0
  112. data/lib/u3d_core/command_executor.rb +134 -0
  113. data/lib/u3d_core/command_runner.rb +93 -0
  114. data/lib/u3d_core/credentials.rb +116 -0
  115. data/lib/u3d_core/globals.rb +84 -0
  116. data/lib/u3d_core/helper.rb +149 -0
  117. data/lib/u3d_core/ui/disable_colors.rb +40 -0
  118. data/lib/u3d_core/ui/implementations/shell.rb +157 -0
  119. data/lib/u3d_core/ui/interface.rb +182 -0
  120. data/lib/u3d_core/ui/ui.rb +49 -0
  121. data/local_gem_install.sh +6 -0
  122. data/scripts/be +14 -0
  123. data/u3d.gemspec +41 -0
  124. metadata +388 -0
@@ -0,0 +1,307 @@
1
+ ## --- BEGIN LICENSE BLOCK ---
2
+ # Copyright (c) 2016-present WeWantToKnow AS
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in all
12
+ # copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ # SOFTWARE.
21
+ ## --- END LICENSE BLOCK ---
22
+
23
+ require 'u3d/unity_versions'
24
+ require 'u3d/downloader'
25
+ require 'u3d/installer'
26
+ require 'u3d/cache'
27
+ require 'u3d/utils'
28
+ require 'u3d/log_analyzer'
29
+ require 'u3d_core/command_executor'
30
+ require 'u3d_core/credentials'
31
+ require 'fileutils'
32
+
33
+ module U3d
34
+ # API for U3d, redirecting calls to class they concern
35
+ class Commands
36
+ class << self
37
+ def list_installed(options: {})
38
+ list = Installer.create.installed
39
+ if list.empty?
40
+ UI.important 'No Unity version installed'
41
+ return
42
+ end
43
+ list.each do |u|
44
+ UI.message "Version #{u.version}\t(#{u.path})"
45
+ packages = u.packages
46
+ next unless options[:packages] && packages && !packages.empty?
47
+ UI.message 'Packages:'
48
+ packages.each { |pack| UI.message " - #{pack}" }
49
+ end
50
+ end
51
+
52
+ def list_available(options: {})
53
+ ver = options[:unity_version]
54
+ os = options[:operating_system]
55
+ rl = options[:release_level]
56
+ if os
57
+ os = os.to_sym
58
+ oses = U3dCore::Helper.operating_systems
59
+ raise "Specified OS (#{os}) isn't valid [#{oses.join(', ')}]" unless oses.include?(os)
60
+ else
61
+ os = U3dCore::Helper.operating_system
62
+ end
63
+ cache = Cache.new(force_os: os, force_refresh: options[:force])
64
+ versions = {}
65
+
66
+ return UI.error "Version #{ver} is not in cache" if ver && cache[os.id2name]['versions'][ver].nil?
67
+
68
+ versions = if ver
69
+ { ver => cache[os.id2name]['versions'][ver] }
70
+ else
71
+ cache[os.id2name]['versions']
72
+ end
73
+
74
+ vcomparators = versions.keys.map { |k| UnityVersionComparator.new(k) }
75
+ if rl
76
+ letter = release_letter_mapping["latest_#{rl}".to_sym]
77
+ UI.message "Filtering available versions with release level '#{rl}' [letter '#{letter}']"
78
+ vcomparators.select! { |vc| vc.version.parts[3] == letter }
79
+ end
80
+ sorted_keys = vcomparators.sort.map { |v| v.version.to_s }
81
+
82
+ sorted_keys.each do |k|
83
+ v = versions[k]
84
+ UI.message "Version #{k}: " + v.to_s.cyan.underline
85
+ next unless options[:packages]
86
+ inif = nil
87
+ begin
88
+ inif = U3d::INIparser.load_ini(k, versions, os: os)
89
+ rescue => e
90
+ UI.error "Could not load packages for this version (#{e})"
91
+ else
92
+ UI.message 'Packages:'
93
+ inif.keys.each { |pack| UI.message " - #{pack}" }
94
+ end
95
+ end
96
+ end
97
+
98
+ def download(args: [], options: {})
99
+ version = args[0]
100
+ UI.user_error!('Please specify a Unity version to download') unless version
101
+
102
+ packages = packages_with_unity_first(options)
103
+
104
+ os = U3dCore::Helper.operating_system
105
+ cache = Cache.new(force_os: os)
106
+ versions = cache[os.id2name]['versions']
107
+ version = interpret_latest(version, versions)
108
+
109
+ unless packages.include?('Unity')
110
+ unity = check_unity_presence(version: version)
111
+ return unless unity
112
+ options[:installation_path] ||= unity.path if Helper.windows?
113
+ end
114
+
115
+ U3d::Globals.use_keychain = true if options[:keychain] && Helper.mac?
116
+
117
+ unless options[:no_install]
118
+ UI.important 'Root privileges are required'
119
+ raise 'Could not get administrative privileges' unless U3dCore::CommandExecutor.has_admin_privileges?
120
+ end
121
+
122
+ files = []
123
+ if os == :linux
124
+ UI.important 'Option -a | --all not available for Linux' if options[:all]
125
+ UI.important 'Option -p | --packages not available for Linux' if options[:packages]
126
+ downloader = Downloader::LinuxDownloader
127
+ files << ["Unity #{version}", downloader.download(version, versions), {}]
128
+ else
129
+ downloader = Downloader::MacDownloader if os == :mac
130
+ downloader = Downloader::WindowsDownloader if os == :win
131
+ if options[:all]
132
+ files = downloader.download_all(version, versions)
133
+ else
134
+ packages.each do |package|
135
+ result = downloader.download_specific(package, version, versions)
136
+ files << [package, result[0], result[1]] unless result.nil?
137
+ end
138
+ end
139
+ end
140
+
141
+ return if options[:no_install]
142
+ files.each do |name, file, info|
143
+ UI.verbose "Installing #{name}#{info['mandatory'] ? ' (mandatory package)' : ''}, with file #{file}"
144
+ Installer.install_module(file, version, installation_path: options[:installation_path], info: info)
145
+ end
146
+ end
147
+
148
+ def local_install(args: [], options: {})
149
+ UI.user_error!('Please specify a version') if args.empty?
150
+ version = args[0]
151
+
152
+ packages = packages_with_unity_first(options)
153
+
154
+ unless packages.include?('Unity')
155
+ unity = check_unity_presence(version: version)
156
+ return unless unity
157
+ options[:installation_path] ||= unity.path if Helper.windows?
158
+ end
159
+
160
+ U3d::Globals.use_keychain = true if options[:keychain] && Helper.mac?
161
+
162
+ UI.important 'Root privileges are required'
163
+ raise 'Could not get administrative privileges' unless U3dCore::CommandExecutor.has_admin_privileges?
164
+
165
+ os = U3dCore::Helper.operating_system
166
+ files = []
167
+ if os == :linux
168
+ UI.important 'Option -a | --all not available for Linux' if options[:all]
169
+ UI.important 'Option -p | --packages not available for Linux' if options[:packages]
170
+ downloader = Downloader::LinuxDownloader
171
+ files << ["Unity #{version}", downloader.local_file(version), {}]
172
+ else
173
+ downloader = Downloader::MacDownloader if os == :mac
174
+ downloader = Downloader::WindowsDownloader if os == :win
175
+ if options[:all]
176
+ files = downloader.all_local_files(version)
177
+ else
178
+ packages.each do |package|
179
+ result = downloader.local_file(package, version)
180
+ files << [package, result[0], result[1]] unless result.nil?
181
+ end
182
+ end
183
+ end
184
+
185
+ files.each do |name, file, info|
186
+ UI.verbose "Installing #{name}#{info['mandatory'] ? ' (mandatory package)' : ''}, with file #{file}"
187
+ Installer.install_module(file, version, installation_path: options[:installation_path], info: info)
188
+ end
189
+ end
190
+
191
+ def run(options: {}, run_args: [])
192
+ version = options[:unity_version]
193
+
194
+ runner = Runner.new
195
+ pp = runner.find_projectpath_in_args(run_args)
196
+ pp = Dir.pwd unless pp
197
+ up = UnityProject.new(pp)
198
+
199
+ unless version # fall back in project default if we are on a Unity project
200
+ version = up.editor_version if up.exist?
201
+ unless version
202
+ UI.user_error!('Not sure which version of Unity to run. Are you in a project?')
203
+ end
204
+ end
205
+
206
+ run_args = ['-projectpath', up.path] if run_args.empty? && up.exist?
207
+
208
+ # we could
209
+ # * support matching 5.3.6p3 if passed 5.3.6
210
+ unity = Installer.create.installed.find { |u| u.version == version }
211
+ UI.user_error! "Unity version '#{version}' not found" unless unity
212
+ runner.run(unity, run_args, raw_logs: options[:raw_logs])
213
+ end
214
+
215
+ def credentials_actions
216
+ %w(add remove check)
217
+ end
218
+
219
+ def credentials(args: [], options: {})
220
+ action = args[0]
221
+ raise "Please specify an action to perform, one of #{credentials_actions.join(',')}" unless action
222
+ raise "Unknown action '#{action}'. Use one of #{credentials_actions.join(',')}" unless credentials_actions.include? action
223
+ if action == 'add'
224
+ U3dCore::Globals.use_keychain = true
225
+ # credentials = U3dCore::Credentials.new(user: ENV['USER'])
226
+ # credentials.login # ask password
227
+ UI.error 'Invalid credentials' unless U3dCore::CommandExecutor.has_admin_privileges?
228
+ elsif action == 'remove'
229
+ U3dCore::Globals.use_keychain = true
230
+ U3dCore::Credentials.new(user: ENV['USER']).forget_credentials(force: true)
231
+ else
232
+ U3dCore::Globals.use_keychain = true
233
+ credentials = U3dCore::Credentials.new(user: ENV['USER'])
234
+ U3dCore::Globals.with_do_not_login(true) do
235
+ if credentials.password.to_s.empty?
236
+ UI.message "No credentials stored"
237
+ else
238
+ if U3dCore::CommandExecutor.has_admin_privileges?
239
+ UI.success "Stored credentials are valid"
240
+ else
241
+ UI.error "Stored credentials are not valid"
242
+ end
243
+ end
244
+ end
245
+ # FIXME: return value
246
+ end
247
+ end
248
+
249
+ def local_analyze(args: [])
250
+ raise ArgumentError, 'No files given' if args.empty?
251
+ raise ArgumentError, "File #{args[0]} does not exist" unless File.exist? args[0]
252
+
253
+ analyzer = LogAnalyzer.new
254
+ File.open(args[0], 'r') do |f|
255
+ f.readlines.each { |l| analyzer.parse_line l }
256
+ end
257
+ end
258
+
259
+ def release_levels
260
+ [:stable, :beta, :patch]
261
+ end
262
+
263
+ def release_letter_mapping
264
+ {
265
+ latest: 'f',
266
+ latest_stable: 'f',
267
+ latest_beta: 'b',
268
+ latest_patch: 'p'
269
+ }
270
+ end
271
+
272
+ private
273
+
274
+ def interpret_latest(version, versions)
275
+ return version unless release_letter_mapping.keys.include? version.to_sym
276
+
277
+ letter = release_letter_mapping[version.to_sym]
278
+
279
+ iversion = versions.keys.map { |k| UnityVersionComparator.new(k) }
280
+ .sort
281
+ .reverse
282
+ .find { |c| c.version.parts[3] == letter }
283
+ .version.to_s
284
+ UI.message "Version '#{version}' is #{iversion}."
285
+ iversion
286
+ end
287
+
288
+ def packages_with_unity_first(options)
289
+ temp = options[:packages] || ['Unity']
290
+ temp.insert(0, 'Unity') if temp.delete('Unity')
291
+ temp
292
+ end
293
+
294
+ def check_unity_presence(version: nil)
295
+ installed = Installer.create.installed
296
+ unity = installed.find { |u| u.version == version }
297
+ if unity.nil?
298
+ UI.error "Version #{version} of Unity is not installed yet. Please install it first before installing any other module"
299
+ else
300
+ UI.verbose "Unity #{version} is installed at #{unity.path}"
301
+ return unity
302
+ end
303
+ nil
304
+ end
305
+ end
306
+ end
307
+ end
@@ -0,0 +1,163 @@
1
+ ## --- BEGIN LICENSE BLOCK ---
2
+ # Copyright (c) 2016-present WeWantToKnow AS
3
+ #
4
+ # Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ # of this software and associated documentation files (the "Software"), to deal
6
+ # in the Software without restriction, including without limitation the rights
7
+ # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ # copies of the Software, and to permit persons to whom the Software is
9
+ # furnished to do so, subject to the following conditions:
10
+ #
11
+ # The above copyright notice and this permission notice shall be included in all
12
+ # copies or substantial portions of the Software.
13
+ #
14
+ # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ # SOFTWARE.
21
+ ## --- END LICENSE BLOCK ---
22
+
23
+ require 'commander'
24
+ require 'u3d_core'
25
+ require 'u3d/commands'
26
+
27
+ HighLine.track_eof = false
28
+
29
+ module U3d
30
+ # CLI using commander gem for u3d
31
+ class CommandsGenerator
32
+ include Commander::Methods
33
+ UI = U3dCore::UI
34
+
35
+ def self.start
36
+ new.run
37
+ end
38
+
39
+ def extract_run_args(args = ARGV)
40
+ both_args = [[], []]
41
+ idx = 0
42
+ args.each do |arg|
43
+ if arg == '--'
44
+ idx = 1
45
+ next
46
+ end
47
+ both_args[idx] << arg
48
+ end
49
+ args.replace both_args[0]
50
+ both_args[1]
51
+ end
52
+
53
+ def convert_options(options)
54
+ o = options.__hash__.dup
55
+ o.delete(:verbose)
56
+ o
57
+ end
58
+
59
+ def run
60
+ program :version, U3d::VERSION
61
+ program :description, U3d::DESCRIPTION
62
+ program :help, 'Authors', 'Jerome Lacoste <jerome@wewanttoknow.com>, Paul Niezborala <p.niezborala@wewanttoknow.com>'
63
+ program :help, 'A word on Unity versions', U3d::UNITY_VERSIONS_NOTE
64
+
65
+ global_option('--verbose') { U3dCore::Globals.verbose = true }
66
+
67
+ command :run do |c|
68
+ # Intended for backward compatibilty purposes for run command
69
+ # Meant to fetch options after '--' unknown by CommandsGenerator
70
+ run_args = extract_run_args
71
+
72
+ c.syntax = 'u3d run [-u | --unity_version <version>] [-r | --raw_logs] [ -- <run_args>]'
73
+ c.description = 'Run unity, and parses its output through u3d\'s log prettifier'
74
+ c.option '-u', '--unity_version STRING', String, 'Version of Unity to run with'
75
+ c.option '-r', '--raw_logs', 'Raw Unity output, not filtered by u3d\'s log prettifier'
76
+ c.action do |args, options|
77
+ UI.user_error! "Run doesn't take arguments. Did you forget '--' or did you mistake your command? (#{args})" if args.count > 0
78
+ U3dCore::Globals.log_timestamps = true
79
+ Commands.run(options: convert_options(options), run_args: run_args)
80
+ end
81
+ end
82
+
83
+ command :list do |c|
84
+ c.syntax = 'u3d list [-p | --packages]'
85
+ c.option '-p', '--packages', 'Lists installed packages as well'
86
+ c.example 'List currently installed Unity3d versions, as well as installed packages', 'u3d list -p'
87
+ c.description = 'List installed version of Unity3d'
88
+ c.action do |_args, options|
89
+ Commands.list_installed(options: convert_options(options))
90
+ end
91
+ end
92
+
93
+ command :available do |c|
94
+ oses = U3dCore::Helper.operating_systems
95
+ c.syntax = 'u3d available [-r | --release_level <level>] [-o | --operating_system <OS>] [-u | --unity_version <version>] [-p | --packages] [-f | --force]'
96
+ levels = Commands.release_levels
97
+ c.option '-f', '--force', 'Force refresh list of available versions'
98
+ c.option '-r', '--release_level STRING', String, "Checks for availability on specific release level [#{levels.join(',')}]"
99
+ c.option '-o', '--operating_system STRING', String, "Checks for availability on specific OS [#{oses.join(', ')}]"
100
+ c.option '-u', '--unity_version STRING', String, 'Checks if specified version is available'
101
+ c.option '-p', '--packages', 'Lists available packages as well'
102
+ c.example 'List all versions available, forcing a refresh of the available packages from Unity servers', 'u3d available -f'
103
+ c.example 'List stable versions available', 'u3d available -r stable -p'
104
+ c.example 'List all versions available for Linux platform', 'u3d available -o linux'
105
+ c.example 'List packages available for Unity version 5.6.0f3', 'u3d available -u 5.6.0f3 -p'
106
+ c.description = 'List download-ready versions of Unity3d'
107
+ c.action do |_args, options|
108
+ options.default packages: false
109
+ Commands.list_available(options: convert_options(options))
110
+ end
111
+ end
112
+
113
+ command :install do |c|
114
+ c.syntax = 'u3d install <version> [ [-p | --packages <package> ...] | [-a | --all] ] [ [-n | --no_install] [-i | --installation_path <path>] ]'
115
+ c.description = "Download (and install) Unity3D packages."
116
+ c.option '-p', '--packages PACKAGES', Array, 'Specifies which packages to download. Overriden by --all'
117
+ c.option '-i', '--installation_path PATH', String, 'Specifies where package(s) will be installed. Overriden by --no_install'
118
+ c.option '-a', '--all', 'Download all available packages'
119
+ c.option '-n', '--no_install', 'No installation after download success'
120
+ c.option '-k', '--keychain', 'Gain privileges right through the keychain. [OSX only]'
121
+ c.example 'Download and install Unity, its Documentation and the Android build support and install them for version 5.1.2f1', 'u3d install 5.1.2f1 -p Unity,Documentation,Android'
122
+ c.example "The 'version' argument can be a specific version number, such as 5.6.1f1, or an alias in [#{Commands.release_letter_mapping.keys.join(',')}]", 'u3d install latest'
123
+ c.action do |args, options|
124
+ options.default all: false
125
+ options.default no_install: false
126
+ Commands.download(args: args, options: convert_options(options))
127
+ end
128
+ end
129
+
130
+ command :local_install do |c|
131
+ c.syntax = 'u3d local_install <version> [ [-p | --packages <package> ...] | [-a | --all] ] [-i | --installation_path <path>]'
132
+ c.description = 'Install downloaded version of unity'
133
+ c.option '-p', '--packages PACKAGES', Array, 'Specifies which packages to install. Overriden by --all'
134
+ c.option '-i', '--installation_path PATH', String, 'Specifies where package(s) will be installed.'
135
+ c.option '-a', '--all', 'Install all downloaded packages'
136
+ c.option '-k', '--keychain', 'Gain privileges right through the keychain. [OSX only]'
137
+ c.action do |args, options|
138
+ Commands.local_install(args: args, options: convert_options(options))
139
+ end
140
+ end
141
+
142
+ command :credentials do |c|
143
+ c.syntax = "u3d credentials <#{Commands.credentials_actions.join(' | ')}>"
144
+ c.description = 'Manages keychain credentials so u3d remembers them. [OSX only]'
145
+ c.action do |args, options|
146
+ Commands.credentials(args: args, options: convert_options(options))
147
+ end
148
+ end
149
+
150
+ command :prettify do |c|
151
+ c.syntax = 'u3d prettify <logfile>'
152
+ c.description = 'Prettify a saved logfile'
153
+ c.action do |args, _options|
154
+ Commands.local_analyze(args: args)
155
+ end
156
+ end
157
+
158
+ default_command :run
159
+
160
+ run!
161
+ end
162
+ end
163
+ end