MuranoCLI 2.2.4 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (159) hide show
  1. checksums.yaml +4 -4
  2. data/.agignore +3 -0
  3. data/.gitignore +18 -1
  4. data/.rubocop.yml +222 -0
  5. data/.trustme.sh +185 -0
  6. data/.trustme.vim +24 -0
  7. data/Gemfile +23 -4
  8. data/LICENSE.txt +1 -1
  9. data/MuranoCLI.gemspec +43 -8
  10. data/README.markdown +9 -11
  11. data/Rakefile +187 -143
  12. data/TODO.taskpaper +2 -2
  13. data/bin/murano +51 -52
  14. data/docs/basic_example.rst +436 -0
  15. data/docs/completions/murano_completion-bash +3484 -0
  16. data/docs/demo.md +32 -32
  17. data/docs/develop.rst +391 -0
  18. data/lib/MrMurano.rb +21 -7
  19. data/lib/MrMurano/Account.rb +159 -174
  20. data/lib/MrMurano/Business.rb +381 -0
  21. data/lib/MrMurano/Config-Migrate.rb +32 -26
  22. data/lib/MrMurano/Config.rb +407 -128
  23. data/lib/MrMurano/Content.rb +191 -0
  24. data/lib/MrMurano/Gateway.rb +489 -0
  25. data/lib/MrMurano/Keystore.rb +48 -0
  26. data/lib/MrMurano/Passwords.rb +103 -0
  27. data/lib/MrMurano/ProjectFile.rb +121 -79
  28. data/lib/MrMurano/ReCommander.rb +114 -10
  29. data/lib/MrMurano/Setting.rb +90 -0
  30. data/lib/MrMurano/Solution-ServiceConfig.rb +89 -45
  31. data/lib/MrMurano/Solution-Services.rb +461 -166
  32. data/lib/MrMurano/Solution-Users.rb +70 -31
  33. data/lib/MrMurano/Solution.rb +372 -13
  34. data/lib/MrMurano/SolutionId.rb +73 -0
  35. data/lib/MrMurano/SyncRoot.rb +137 -0
  36. data/lib/MrMurano/SyncUpDown.rb +594 -284
  37. data/lib/MrMurano/Webservice-Cors.rb +71 -0
  38. data/lib/MrMurano/Webservice-Endpoint.rb +234 -0
  39. data/lib/MrMurano/Webservice-File.rb +193 -0
  40. data/lib/MrMurano/Webservice.rb +51 -0
  41. data/lib/MrMurano/commands.rb +18 -15
  42. data/lib/MrMurano/commands/business.rb +300 -6
  43. data/lib/MrMurano/commands/completion-bash.erb +166 -0
  44. data/lib/MrMurano/commands/{zshcomplete.erb → completion-zsh.erb} +0 -0
  45. data/lib/MrMurano/commands/completion.rb +76 -39
  46. data/lib/MrMurano/commands/config.rb +108 -44
  47. data/lib/MrMurano/commands/content.rb +115 -72
  48. data/lib/MrMurano/commands/cors.rb +29 -14
  49. data/lib/MrMurano/commands/devices.rb +286 -0
  50. data/lib/MrMurano/commands/domain.rb +52 -12
  51. data/lib/MrMurano/commands/gb.rb +24 -9
  52. data/lib/MrMurano/commands/globals.rb +64 -0
  53. data/lib/MrMurano/commands/init.rb +377 -155
  54. data/lib/MrMurano/commands/keystore.rb +92 -82
  55. data/lib/MrMurano/commands/link.rb +300 -0
  56. data/lib/MrMurano/commands/login.rb +74 -11
  57. data/lib/MrMurano/commands/logs.rb +63 -32
  58. data/lib/MrMurano/commands/mock.rb +57 -29
  59. data/lib/MrMurano/commands/password.rb +57 -39
  60. data/lib/MrMurano/commands/postgresql.rb +127 -94
  61. data/lib/MrMurano/commands/settings.rb +203 -0
  62. data/lib/MrMurano/commands/show.rb +79 -38
  63. data/lib/MrMurano/commands/solution.rb +423 -5
  64. data/lib/MrMurano/commands/solution_picker.rb +547 -0
  65. data/lib/MrMurano/commands/status.rb +195 -61
  66. data/lib/MrMurano/commands/sync.rb +78 -39
  67. data/lib/MrMurano/commands/timeseries.rb +71 -55
  68. data/lib/MrMurano/commands/tsdb.rb +113 -87
  69. data/lib/MrMurano/commands/usage.rb +57 -15
  70. data/lib/MrMurano/hash.rb +100 -10
  71. data/lib/MrMurano/http.rb +187 -43
  72. data/lib/MrMurano/makePretty.rb +16 -14
  73. data/lib/MrMurano/optparse.rb +2178 -0
  74. data/lib/MrMurano/progress.rb +138 -0
  75. data/lib/MrMurano/schema/resource-v1.0.0.yaml +32 -0
  76. data/lib/MrMurano/template/projectFile.murano.erb +16 -13
  77. data/lib/MrMurano/verbosing.rb +166 -29
  78. data/lib/MrMurano/version.rb +30 -1
  79. data/spec/Account-Passwords_spec.rb +21 -4
  80. data/spec/Account_spec.rb +69 -146
  81. data/spec/Business_spec.rb +290 -0
  82. data/spec/ConfigFile_spec.rb +1 -0
  83. data/spec/ConfigMigrate_spec.rb +12 -8
  84. data/spec/Config_spec.rb +40 -34
  85. data/spec/Content_spec.rb +363 -0
  86. data/spec/GatewayBase_spec.rb +54 -0
  87. data/spec/GatewayDevice_spec.rb +321 -0
  88. data/spec/GatewayResource_spec.rb +266 -0
  89. data/spec/GatewaySettings_spec.rb +120 -0
  90. data/spec/Http_spec.rb +18 -8
  91. data/spec/Mock_spec.rb +2 -2
  92. data/spec/ProjectFile_spec.rb +25 -14
  93. data/spec/Setting_spec.rb +110 -0
  94. data/spec/Solution-ServiceConfig_spec.rb +44 -5
  95. data/spec/Solution-ServiceEventHandler_spec.rb +23 -14
  96. data/spec/Solution-ServiceModules_spec.rb +47 -37
  97. data/spec/Solution-UsersRoles_spec.rb +10 -8
  98. data/spec/Solution_spec.rb +17 -8
  99. data/spec/SyncRoot_spec.rb +46 -20
  100. data/spec/SyncUpDown_spec.rb +437 -201
  101. data/spec/Verbosing_spec.rb +12 -4
  102. data/spec/{Solution-Cors_spec.rb → Webservice-Cors_spec.rb} +23 -20
  103. data/spec/{Solution-Endpoint_spec.rb → Webservice-Endpoint_spec.rb} +43 -41
  104. data/spec/{Solution-File_spec.rb → Webservice-File_spec.rb} +44 -33
  105. data/spec/Webservice-Setting_spec.rb +89 -0
  106. data/spec/_workspace.rb +4 -4
  107. data/spec/cmd_business_spec.rb +9 -4
  108. data/spec/cmd_common.rb +44 -1
  109. data/spec/cmd_content_spec.rb +43 -17
  110. data/spec/cmd_cors_spec.rb +4 -4
  111. data/spec/cmd_device_spec.rb +61 -16
  112. data/spec/cmd_domain_spec.rb +29 -6
  113. data/spec/cmd_init_spec.rb +281 -126
  114. data/spec/cmd_keystore_spec.rb +3 -3
  115. data/spec/cmd_link_spec.rb +98 -0
  116. data/spec/cmd_password_spec.rb +1 -1
  117. data/spec/cmd_setting_application_spec.rb +260 -0
  118. data/spec/cmd_setting_product_spec.rb +220 -0
  119. data/spec/cmd_status_spec.rb +223 -114
  120. data/spec/cmd_syncdown_spec.rb +115 -35
  121. data/spec/cmd_syncup_spec.rb +68 -15
  122. data/spec/cmd_usage_spec.rb +35 -8
  123. data/spec/fixtures/dumped_config +6 -4
  124. data/spec/fixtures/gateway_resource_files/resources.notyaml +12 -0
  125. data/spec/fixtures/gateway_resource_files/resources.yaml +13 -0
  126. data/spec/fixtures/gateway_resource_files/resources_invalid.yaml +13 -0
  127. data/spec/fixtures/mrmuranorc_deleted_bob +0 -2
  128. data/spec/fixtures/product_spec_files/lightbulb.yaml +20 -13
  129. data/spec/fixtures/{syncable_content → syncable_conflict}/services/devdata.lua +1 -1
  130. data/spec/fixtures/{syncable_content → syncable_conflict}/services/timers.lua +0 -0
  131. data/spec/spec_helper.rb +5 -0
  132. metadata +262 -171
  133. data/bin/mr +0 -8
  134. data/lib/MrMurano/Product-1P-Device.rb +0 -145
  135. data/lib/MrMurano/Product-Resources.rb +0 -205
  136. data/lib/MrMurano/Product.rb +0 -358
  137. data/lib/MrMurano/Solution-Cors.rb +0 -47
  138. data/lib/MrMurano/Solution-Endpoint.rb +0 -191
  139. data/lib/MrMurano/Solution-File.rb +0 -166
  140. data/lib/MrMurano/commands/assign.rb +0 -57
  141. data/lib/MrMurano/commands/businessList.rb +0 -45
  142. data/lib/MrMurano/commands/product.rb +0 -14
  143. data/lib/MrMurano/commands/productCreate.rb +0 -39
  144. data/lib/MrMurano/commands/productDelete.rb +0 -33
  145. data/lib/MrMurano/commands/productDevice.rb +0 -87
  146. data/lib/MrMurano/commands/productDeviceIdCmds.rb +0 -89
  147. data/lib/MrMurano/commands/productList.rb +0 -45
  148. data/lib/MrMurano/commands/productWrite.rb +0 -27
  149. data/lib/MrMurano/commands/solutionCreate.rb +0 -41
  150. data/lib/MrMurano/commands/solutionDelete.rb +0 -34
  151. data/lib/MrMurano/commands/solutionList.rb +0 -45
  152. data/spec/ProductBase_spec.rb +0 -113
  153. data/spec/ProductContent_spec.rb +0 -162
  154. data/spec/ProductResources_spec.rb +0 -329
  155. data/spec/Product_1P_Device_spec.rb +0 -202
  156. data/spec/Product_1P_RPC_spec.rb +0 -175
  157. data/spec/Product_spec.rb +0 -153
  158. data/spec/Solution-ServiceDevice_spec.rb +0 -176
  159. data/spec/cmd_assign_spec.rb +0 -51
@@ -1,30 +1,45 @@
1
+ # Last Modified: 2017.08.16 /coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright © 2016-2017 Exosite LLC.
5
+ # License: MIT. See LICENSE.txt.
6
+ # vim:tw=0:ts=2:sw=2:et:ai
7
+
1
8
  require 'yaml'
2
- require 'MrMurano/Solution-Cors'
9
+ require 'MrMurano/ReCommander'
10
+ require 'MrMurano/Webservice-Cors'
3
11
 
4
12
  command :cors do |c|
5
- c.syntax = %{murano cors}
6
- c.summary = %{Get the CORS for the project.}
7
- c.description = %{Get the CORS for the project.
13
+ c.syntax = %(murano cors)
14
+ c.summary = %(Get the CORS for the project.)
15
+ c.description = %(
16
+ Get the CORS for the project.
8
17
 
9
- Set the CORS with `murano cors set`
10
- }
18
+ Set the CORS with `murano cors set`.
19
+ ).strip
20
+ c.project_not_required = true
11
21
 
12
- c.action do |args,options|
13
- sol = MrMurano::Cors.new
14
- ret = sol.fetch()
22
+ c.action do |args, _options|
23
+ c.verify_arg_count!(args)
24
+ sol = MrMurano::Webservice::Cors.new
25
+ ret = sol.fetch
15
26
  sol.outf ret
16
27
  end
17
28
  end
18
29
 
19
30
  command 'cors set' do |c|
20
- c.syntax = %{murano cors set [<file>]}
21
- c.summary = %{Set the CORS for the project.}
31
+ c.syntax = %(murano cors set [<file>])
32
+ c.summary = %(Set the CORS for the project)
33
+ c.description = %(
34
+ Set the CORS for the project.
35
+ ).strip
36
+ c.project_not_required = true
22
37
 
23
- c.action do |args,options|
24
- crs = MrMurano::Cors.new
38
+ c.action do |args, _options|
39
+ c.verify_arg_count!(args, 1, ['Missing <file>'])
40
+ crs = MrMurano::Webservice::Cors.new
25
41
  file = args.shift
26
42
  crs.upload(file)
27
43
  end
28
44
  end
29
45
 
30
- # vim: set ai et sw=2 ts=2 :
@@ -0,0 +1,286 @@
1
+ # Last Modified: 2017.08.16 /coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright © 2016-2017 Exosite LLC.
5
+ # License: MIT. See LICENSE.txt.
6
+ # vim:tw=0:ts=2:sw=2:et:ai
7
+
8
+ require 'MrMurano/Gateway'
9
+ require 'MrMurano/ReCommander'
10
+
11
+ command 'device' do |c|
12
+ c.syntax = %(murano device)
13
+ c.summary = %(Interact with a device)
14
+ c.description = %(
15
+ Interact with a device.
16
+ ).strip
17
+ c.project_not_required = true
18
+
19
+ c.action do |_args, _options|
20
+ ::Commander::UI.enable_paging
21
+ say MrMurano::SubCmdGroupHelp.new(c).get_help
22
+ end
23
+ end
24
+
25
+ command 'device list' do |c|
26
+ c.syntax = %(murano device list [--options])
27
+ c.summary = %(List identifiers for a product)
28
+ c.description = %(
29
+ List identifiers for a product.
30
+ ).strip
31
+
32
+ c.option '--limit NUMBER', Integer, %(How many devices to return)
33
+ c.option '--before TIMESTAMP', Integer, %(Show devices before timestamp)
34
+ c.option '-l', '--long', %(show everything)
35
+ c.option '-o', '--output FILE', %(Download to file instead of STDOUT)
36
+
37
+ c.action do |args, options|
38
+ c.verify_arg_count!(args)
39
+ #options.default limit: 1000
40
+
41
+ prd = MrMurano::Gateway::Device.new
42
+ MrMurano::Verbose.whirly_start 'Looking for devices...'
43
+ data = prd.list(options.limit, options.before)
44
+ MrMurano::Verbose.whirly_stop
45
+ exit 1 if data.nil?
46
+
47
+ if !data[:devices].empty?
48
+ io = File.open(options.output, 'w') if options.output
49
+ prd.outf(data, io) do |_dd, ios|
50
+ dt = {}
51
+ if options.long
52
+ dt[:headers] = [
53
+ :Identifier,
54
+ :AuthType,
55
+ :Locked,
56
+ :Reprovision,
57
+ 'Dev Mode',
58
+ 'Last IP',
59
+ 'Last Seen',
60
+ :Status,
61
+ :Online,
62
+ ]
63
+ dt[:rows] = data[:devices].map do |row|
64
+ [
65
+ row[:identity],
66
+ (row[:auth] || {})[:type],
67
+ row[:locked],
68
+ row[:reprovision],
69
+ row[:devmode],
70
+ row[:lastip],
71
+ row[:lastseen],
72
+ row[:status],
73
+ row[:online],
74
+ ]
75
+ end
76
+ else
77
+ dt[:headers] = %i[Identifier Status Online]
78
+ dt[:rows] = data[:devices].map do |row|
79
+ [row[:identity], row[:status], row[:online]]
80
+ end
81
+ end
82
+ prd.tabularize(dt, ios)
83
+ end
84
+ io.close unless io.nil?
85
+ else
86
+ prd.warning 'Did not find any devices'
87
+ end
88
+ end
89
+ end
90
+ alias_command 'devices list', 'device list'
91
+
92
+ command 'device read' do |c|
93
+ c.syntax = %(murano device read <identifier> (<alias>...))
94
+ c.summary = %(Read state of a device)
95
+ c.description = %(
96
+ Read state of a device.
97
+
98
+ This reads the latest state values for the resources in a device.
99
+ ).strip
100
+
101
+ c.option '-o', '--output FILE', %(Download to file instead of STDOUT)
102
+
103
+ c.action do |args, options|
104
+ c.verify_arg_count!(args, nil, ['Identifier missing'])
105
+
106
+ prd = MrMurano::Gateway::Device.new
107
+
108
+ snid = args.shift
109
+
110
+ # FIXME/2017-06-14: Confirm that whirly is helpful here.
111
+ MrMurano::Verbose.whirly_start 'Fetching device data...'
112
+ data = prd.read(snid)
113
+ MrMurano::Verbose.whirly_stop
114
+ exit 1 if data.nil?
115
+
116
+ io = File.open(options.output, 'w') if options.output
117
+ data.select! { |k, _v| args.include? k.to_s } unless args.empty?
118
+ prd.outf(data, io) do |dd, ios|
119
+ rows = []
120
+ dd.each_pair do |k, v|
121
+ rows << [k, v[:reported], v[:set], v[:timestamp]]
122
+ end
123
+ prd.tabularize(
124
+ {
125
+ headers: %i[Alias Reported Set Timestamp],
126
+ rows: rows,
127
+ },
128
+ ios
129
+ )
130
+ end
131
+ io.close unless io.nil?
132
+ end
133
+ end
134
+
135
+ command 'device write' do |c|
136
+ c.syntax = %(murano device write <identifier> <Alias=Value> [<Alias=Value>...])
137
+ c.summary = %(Write to 'set' of aliases on devices)
138
+ c.description = %(
139
+ Write to 'set' of aliases on devices.
140
+
141
+ If an alias is not settable, this will fail.
142
+ ).strip
143
+
144
+ c.action do |args, _options|
145
+ c.verify_arg_count!(args, nil, ['Identifier missing'])
146
+
147
+ resources = (MrMurano::Gateway::GweBase.new.info || {})[:resources]
148
+
149
+ prd = MrMurano::Gateway::Device.new
150
+
151
+ snid = args.shift
152
+
153
+ set = Hash[args.map { |i| i.split('=') }]
154
+ set.each_pair do |k, v|
155
+ fmt = ((resources[k.to_sym] || {})[:format] || 'string')
156
+ case fmt
157
+ when 'number'
158
+ if v.to_f.to_i == v.to_i
159
+ set[k] = v.to_i
160
+ else
161
+ set[k] = v.to_f
162
+ end
163
+ when 'string'
164
+ set[k] = '' if v.nil?
165
+ when 'boolean'
166
+ set[k] = %w[1 yes true on].include?(v.downcase)
167
+ end
168
+ end
169
+
170
+ ret = prd.write(snid, set)
171
+ # On success, write returns empty curlies {}. So check nil or empty.
172
+ prd.outf(ret) unless ret.nil? || ret.empty?
173
+ end
174
+ end
175
+
176
+ command 'device enable' do |c|
177
+ c.syntax = %(murano device enable [<identifier>|--file <identifiers>])
178
+ c.summary = %(Enable an Identifier; Creates device in Murano)
179
+ c.description = %(
180
+ Enables Identifiers, creating the digial shadow in Murano.
181
+ ).strip
182
+
183
+ c.option '-f', '--file FILE', %(A file of serial numbers, one per line)
184
+ c.option '--key FILE', %(Public TLS key for this device)
185
+
186
+ c.action do |args, options|
187
+ # SKIP: c.verify_arg_count!(args)
188
+ prd = MrMurano::Gateway::Device.new
189
+ if !options.file.nil? && !options.key.nil?
190
+ prd.error %(Cannot use both --file and --key)
191
+ exit 1
192
+ end
193
+ if options.file
194
+ # Check file for headers.
195
+ header = File.new(options.file).gets
196
+ if header.nil?
197
+ prd.error 'Nothing in file!'
198
+ exit 1
199
+ end
200
+ unless header =~ /\s*ID\s*(,SSL Client Certificate\s*)?/
201
+ prd.error "Missing column headers in file \"#{options.file}\""
202
+ prd.error %(First line in file should be either "ID" or "ID, SSL Client Certificate")
203
+ exit 2
204
+ end
205
+ prd.enable_batch(options.file)
206
+ elsif args.count > 0
207
+ if options.key
208
+ File.open(options.key, 'rb') do |io|
209
+ prd.enable(args[0], type: :certificate, publickey: io)
210
+ end
211
+ else
212
+ prd.enable(args[0])
213
+ end
214
+ else
215
+ prd.error 'Missing an Identifier to enable'
216
+ end
217
+ end
218
+ end
219
+
220
+ command 'device activate' do |c|
221
+ c.syntax = %(murano device activate <identifier>)
222
+ c.summary = %(Activate a serial number, retriving its CIK)
223
+ c.description = %(
224
+ Activate an Identifier.
225
+
226
+ Generally you should not use this.
227
+
228
+ Instead, the device should make the activation call itself
229
+ and save the CIK token.
230
+
231
+ But sometimes when building a proof-of-concept it is just
232
+ easier to hardcode the CIK.
233
+
234
+ Note that you can only activate a device once. After that
235
+ you cannot retrive the CIK again.
236
+ ).strip
237
+
238
+ c.action do |args, _options|
239
+ c.verify_arg_count!(args, nil, ['Identifier missing'])
240
+ prd = MrMurano::Gateway::Device.new
241
+ prd.outf prd.activate(args.first)
242
+ end
243
+ end
244
+
245
+ command 'device delete' do |c|
246
+ c.syntax = %(murano device delete <identifier>)
247
+ c.summary = %(Delete a device)
248
+ c.description = %(
249
+ Delete a device.
250
+ ).strip
251
+
252
+ c.action do |args, _options|
253
+ c.verify_arg_count!(args, nil, ['Identifier missing'])
254
+ prd = MrMurano::Gateway::Device.new
255
+ snid = args.shift
256
+ ret = prd.remove(snid)
257
+ prd.outf ret unless ret.empty?
258
+ end
259
+ end
260
+
261
+ command 'device httpurl' do |c|
262
+ c.syntax = %(murano device httpurl)
263
+ c.summary = %(Get the URL for the HTTP-Data-API for this Project)
264
+ c.description = %(
265
+ Get the URL for the HTTP-Data-API for this Project.
266
+ ).strip
267
+
268
+ c.action do |args, _options|
269
+ c.verify_arg_count!(args)
270
+ prd = MrMurano::Gateway::GweBase.new
271
+ ret = prd.info
272
+ say "https://#{ret[:fqdn]}/onep:v1/stack/alias"
273
+ end
274
+ end
275
+
276
+ alias_command 'product device', 'device'
277
+ alias_command 'product device list', 'device list'
278
+ alias_command 'product devices list', 'device list'
279
+ alias_command 'product device read', 'device read'
280
+ alias_command 'product device twee', 'device read'
281
+ alias_command 'product device write', 'device write'
282
+ alias_command 'product device enable', 'device enable'
283
+ alias_command 'product device activate', 'device activate'
284
+ alias_command 'product device delete', 'device delete'
285
+ alias_command 'product device httpurl', 'device httpurl'
286
+
@@ -1,17 +1,57 @@
1
+ # Last Modified: 2017.08.16 /coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright © 2016-2017 Exosite LLC.
5
+ # License: MIT. See LICENSE.txt.
6
+ # vim:tw=0:ts=2:sw=2:et:ai
7
+
8
+ require 'MrMurano/ReCommander'
1
9
  require 'MrMurano/Solution'
10
+ require 'MrMurano/commands/solution'
11
+
2
12
  command :domain do |c|
3
- c.syntax = %{murano domain}
4
- c.summary = %{Print the domain for this solution}
5
- c.option '--[no-]raw', %{Don't add scheme}
6
- c.action do |args,options|
7
- options.default :raw=>true
8
- sol = MrMurano::Solution.new
9
- ret = sol.info()
10
- if options.raw then
11
- say ret[:domain]
12
- else
13
- say "https://#{ret[:domain]}"
13
+ c.syntax = %(murano domain)
14
+ c.summary = %(Print the domain for this solution)
15
+ c.description = %(
16
+ Print the domain for this solution.
17
+ ).strip
18
+
19
+ c.option '--[no-]raw', %(Don't add scheme (default with brief))
20
+ c.option '--[no-]brief', %(Show fewer fields: only the URL)
21
+ c.option '--[no-]all', 'Show domains for all Solutions in Business, not just Project'
22
+
23
+ # Add flag: --type [application|product|all].
24
+ cmd_add_solntype_pickers(c)
25
+
26
+ c.action do |args, options|
27
+ c.verify_arg_count!(args)
28
+ options.default(all: false)
29
+ options.default(raw: true) if options.brief
30
+ cmd_defaults_solntype_pickers(options)
31
+
32
+ solz = must_fetch_solutions!(options)
33
+
34
+ domain_s = MrMurano::Verbose.pluralize?('domain', solz.length)
35
+ MrMurano::Verbose.whirly_start("Fetching #{domain_s}...")
36
+ solz.each do |soln|
37
+ # Get the solution info; stores the result in the Solution object.
38
+ _meta = soln.info_safe
39
+ end
40
+ MrMurano::Verbose.whirly_stop
41
+
42
+ solz.each do |sol|
43
+ if !options.brief
44
+ say(sol.pretty_desc(add_type: true, raw_url: options.raw))
45
+ elsif options.raw
46
+ say(sol.domain)
47
+ else
48
+ say("https://#{sol.domain}")
49
+ end
14
50
  end
15
51
  end
16
52
  end
17
- # vim: set ai et sw=2 ts=2 :
53
+ alias_command 'domain application', 'domain', '--type', 'application'
54
+ alias_command 'domain product', 'domain', '--type', 'product'
55
+ alias_command 'application domain', 'domain', '--type', 'application'
56
+ alias_command 'product domain', 'domain', '--type', 'product'
57
+
@@ -1,3 +1,10 @@
1
+ # Last Modified: 2017.08.16 /coding: utf-8
2
+ # frozen_string_literal: true
3
+
4
+ # Copyright © 2016-2017 Exosite LLC.
5
+ # License: MIT. See LICENSE.txt.
6
+ # vim:tw=0:ts=2:sw=2:et:ai
7
+
1
8
  require 'pp'
2
9
 
3
10
  # You don't need this.
@@ -6,29 +13,37 @@ require 'pp'
6
13
  # - ln gb.rb ~/.murano/plugins
7
14
 
8
15
  command :_gb do |c|
9
- c.syntax = %{murano _gb <class> <method> (<args>)}
10
- c.summary = %{Call internal class methods directly.}
11
- c.description = %{Call internal class methods directly.}
16
+ c.syntax = %(murano _gb <class> <method> (<args>))
17
+ c.summary = %(Call internal class methods directly)
18
+ c.description = %(
19
+ Call internal class methods directly.
20
+ ).strip
21
+ c.project_not_required = true
22
+
23
+ # Will a plugin need to let user restrict the solution type?
24
+ # Add flag: --type [application|product|all].
25
+ cmd_add_solntype_pickers(c)
12
26
 
13
27
  c.action do |args, options|
28
+ # SKIP: c.verify_arg_count!(args)
29
+ cmd_defaults_solntype_pickers(options)
30
+
14
31
  cls = args[0]
15
32
  meth = args[1].to_sym
16
33
  args.shift(2)
17
34
 
18
35
  begin
19
- gb = Object::const_get("MrMurano::#{cls}").new
20
- if gb.respond_to? meth then
36
+ gb = Object.const_get("MrMurano::#{cls}").new
37
+ if gb.respond_to? meth
21
38
  ret = gb.__send__(meth, *args)
22
- gb.outf(ret) {|o,i| pp o}
39
+ gb.outf(ret) { |o, _i| pp o }
23
40
  else
24
41
  say_error "'#{cls}' doesn't '#{meth}'"
25
42
  end
26
- rescue Exception => e
43
+ rescue StandardError => e
27
44
  say_error e.message
28
45
  pp e
29
46
  end
30
47
  end
31
48
  end
32
49
 
33
-
34
- # vim: set ai et sw=2 ts=2 :