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,45 +0,0 @@
1
- require 'MrMurano/Account'
2
-
3
- command 'business list' do |c|
4
- c.syntax = %{murano business list [options]}
5
- c.description = %{List businesses}
6
- c.option '--idonly', 'Only return the ids'
7
- c.option '--[no-]all', 'Show all fields'
8
- c.option '-o', '--output FILE', %{Download to file instead of STDOUT}
9
-
10
- c.action do |args, options|
11
- acc = MrMurano::Account.new
12
- data = acc.businesses
13
-
14
- io=nil
15
- if options.output then
16
- io = File.open(options.output, 'w')
17
- end
18
-
19
- if options.idonly then
20
- headers = [:bizid]
21
- data = data.map{|row| [row[:bizid]]}
22
- elsif not options.all then
23
- headers = [:bizid, :role, :name]
24
- data = data.map{|r| [r[:bizid], r[:role], r[:name]]}
25
- else
26
- headers = data[0].keys
27
- data = data.map{|r| headers.map{|h| r[h]}}
28
- end
29
-
30
- acc.outf(data, io) do |dd, ios|
31
- if options.idonly then
32
- ios.puts dd.join(' ')
33
- else
34
- acc.tabularize({
35
- :headers=>headers.map{|h| h.to_s},
36
- :rows=>dd
37
- }, ios)
38
- end
39
- end
40
- io.close unless io.nil?
41
-
42
- end
43
- end
44
-
45
- # vim: set ai et sw=2 ts=2 :
@@ -1,14 +0,0 @@
1
- require 'MrMurano/SubCmdGroupContext'
2
-
3
- command :product do |c|
4
- c.syntax = %{murano product}
5
- c.summary = %{About Product}
6
- c.description = %{Sub-commands for working with Products}
7
-
8
- c.action do |args, options|
9
- ::Commander::UI.enable_paging
10
- say MrMurano::SubCmdGroupHelp.new(c).get_help
11
- end
12
- end
13
-
14
- # vim: set ai et sw=2 ts=2 :
@@ -1,39 +0,0 @@
1
-
2
- command 'product create' do |c|
3
- c.syntax = %{murano product create <name>}
4
- c.summary = %{Create a new product}
5
- c.option '--save', %{Save new product id to config}
6
-
7
- c.action do |args, options|
8
- acc = MrMurano::Account.new
9
- if args.count < 1 then
10
- acc.error "Name of product missing"
11
- exit 1
12
- end
13
- name = args[0]
14
-
15
- ret = acc.new_product(name)
16
- if ret.nil? then
17
- acc.error "Create failed"
18
- exit 5
19
- end
20
- if not ret.kind_of?(Hash) and not ret.empty? then
21
- acc.error "Create failed: #{ret.to_s}"
22
- exit 2
23
- end
24
-
25
- # create doesn't return anything, so we need to go look for it.
26
- ret = acc.products.select{|i| i[:label] == name}
27
- pid = ret.first[:modelId]
28
- if pid.nil? or pid.empty? then
29
- acc.error "Didn't find an apiId!!!! #{ret}"
30
- exit 3
31
- end
32
- if options.save then
33
- $cfg.set('product.id', pid)
34
- end
35
- acc.outf pid
36
-
37
- end
38
- end
39
- # vim: set ai et sw=2 ts=2 :
@@ -1,33 +0,0 @@
1
- require 'MrMurano/Account'
2
-
3
- command 'product delete' do |c|
4
- c.syntax = %{murano product delete <product>}
5
- c.summary = %{Delete a product}
6
- c.description = %{Delete a product}
7
-
8
- c.action do |args, options|
9
- acc = MrMurano::Account.new
10
- if args.count < 1 then
11
- acc.error "Product id or name missing"
12
- return
13
- end
14
- name = args[0]
15
-
16
-
17
- # Need to convert what we got into the internal PID.
18
- ret = (acc.products or []).select{|i| i.has_value? name }
19
-
20
- acc.debug "Matches found:"
21
- acc.outf(ret) if $cfg['tool.debug']
22
-
23
- if ret.empty? then
24
- acc.error "No product matching '#{name}' found. Nothing to delete."
25
- else
26
- ret = acc.delete_product(ret.first[:pid])
27
- if not ret.kind_of?(Hash) and not ret.empty? then
28
- acc.error "Delete failed: #{ret.to_s}"
29
- end
30
- end
31
- end
32
- end
33
- # vim: set ai et sw=2 ts=2 :
@@ -1,87 +0,0 @@
1
- require 'MrMurano/Product-1P-Device'
2
-
3
- command 'product device' do |c|
4
- c.syntax = %{murano product device}
5
- c.summary = %{Interact with a device in a product}
6
- c.description = %{Interact with a device in a product}
7
-
8
- c.action do |a,o|
9
- ::Commander::UI.enable_paging
10
- say MrMurano::SubCmdGroupHelp.new(c).get_help
11
- end
12
- end
13
-
14
- command 'product device read' do |c|
15
- c.syntax = %{murano product device read <identifier> (<resources>)}
16
- c.summary = %{Read recources on a device}
17
- c.option '-o', '--output FILE', %{Download to file instead of STDOUT}
18
-
19
- c.action do |args,options|
20
- snid = args.shift
21
- prd = MrMurano::Product1PDevice.new
22
-
23
- if args.count == 0 then
24
- # fetch list and read all
25
- args = prd.list(snid).keys
26
- end
27
-
28
- io=nil
29
- io = File.open(options.output, 'w') if options.output
30
- data = prd.read(snid, args)
31
- prd.outf(data, io)
32
- io.close unless io.nil?
33
-
34
- end
35
- end
36
- alias_command 'device list', 'product device list'
37
-
38
- command 'product device twee' do |c|
39
- c.syntax = %{murano product device twee <identifier>}
40
- c.summary = %{Show info about a device}
41
-
42
-
43
- c.action do |args,options|
44
- options.default :width=>HighLine::SystemExtensions.terminal_size[0]
45
- snid = args.shift
46
- prd = MrMurano::Product1PDevice.new
47
- data = prd.twee(snid)
48
- exit 2 if data.empty?
49
-
50
- io=nil
51
- io = File.open(options.output, 'w') if options.output
52
- prd.outf(data, io) do |dd,ios|
53
- data={}
54
- data[:title] = "#{snid} #{dd[:description][:name]} #{dd[:basic][:status]}"
55
- data[:headers] = [:Resource, :Format, :Modified, :Value]
56
- data[:rows] = dd[:children].map do |child|
57
- [ (child[:description][:name] or child[:alias]),
58
- child[:description][:format],
59
- child[:basic][:modified],
60
- (child[:value] or "").to_s[0..22] # TODO adjust based on terminal width
61
- ]
62
- end
63
- prd.tabularize(data, ios)
64
- end
65
- io.close unless io.nil?
66
- end
67
- end
68
- alias_command 'device twee', 'product device twee'
69
-
70
- command 'product device delete' do |c|
71
- c.syntax = %{murano product device delete <identifier>}
72
- c.summary = %{Delete a device}
73
-
74
- c.action do |args,options|
75
- snid = args.shift
76
- prd = MrMurano::Product1PDevice.new
77
-
78
- ret = prd.remove(snid)
79
- prd.outf ret unless ret.empty?
80
- end
81
- end
82
- alias_command 'device delete', 'product device delete'
83
-
84
- # XXX cannot call this here, since 'sn list' doesn't exist yet.
85
- #alias_command 'product device list', 'sn list'
86
-
87
- # vim: set ai et sw=2 ts=2 :
@@ -1,89 +0,0 @@
1
- require 'MrMurano/Product'
2
- require 'terminal-table'
3
-
4
- command 'product device list' do |c|
5
- c.syntax = %{murano product device list [options]}
6
- c.summary = %{List serial numbers for a product}
7
-
8
- c.option '--offset NUMBER', Integer, %{Offset to start listing at}
9
- c.option '--limit NUMBER', Integer, %{How many devices to return}
10
- c.option '-o', '--output FILE', %{Download to file instead of STDOUT}
11
-
12
- c.action do |args,options|
13
- options.default :offset=>0, :limit=>50
14
-
15
- prd = MrMurano::Product.new
16
- io=nil
17
- io = File.open(options.output, 'w') if options.output
18
- data = prd.list(options.offset, options.limit)
19
- prd.outf(data, nil) do |dd,ios|
20
- dt={}
21
- dt[:headers] = [:SN, :Status, :RID]
22
- dt[:rows] = data.map{|row| [row[:sn], row[:status], row[:rid]]}
23
- prd.tabularize(dt, ios)
24
- end
25
- io.close unless io.nil?
26
- end
27
- end
28
- alias_command 'device list', 'product device list'
29
-
30
- command 'product device enable' do |c|
31
- c.syntax = %{murano product device enable [<sn>|--file <sns>]}
32
- c.summary = %{Enable a serial number; Creates device in Murano}
33
- c.description = %{Enables serial numbers, creating the digial shadow in Murano.
34
-
35
- NOTE: This opens the 24 hour activation window. If the device does not make
36
- the activation call within this time, it will need to be enabled again.
37
- }
38
- c.option '-f', '--file FILE', %{A file of serial numbers, one per line}
39
-
40
- c.action do |args,options|
41
- prd = MrMurano::Product.new
42
- if options.file then
43
- File.open(options.file) do |io|
44
- io.each_line do |line|
45
- line.strip!
46
- prd.enable(line) unless line.empty?
47
- end
48
- end
49
- elsif args.count > 0 then
50
- prd.enable(args[0])
51
- else
52
- prd.error "Missing a serial number to enable"
53
- end
54
- end
55
- end
56
- alias_command 'device enable', 'product device enable'
57
-
58
- command 'product device activate' do |c|
59
- c.syntax = %{murano product device activate <sn>}
60
- c.summary = %{Activate a serial number, retriving its CIK}
61
- c.description = %{Activates a serial number.
62
-
63
- Generally you should not use this. Instead the device should make the activation
64
- call itself and save the CIK token. Its just that sometimes when building a
65
- proof-of-concept it is just easier to hardcode the CIK.
66
-
67
- Note that you can only activate a device once. After that you cannot retrive the
68
- CIK again.
69
- }
70
-
71
- c.action do |args,options|
72
- prd = MrMurano::ProductSerialNumber.new
73
- if args.count < 1 then
74
- prd.error "Serial number missing"
75
- return
76
- end
77
- sn = args.first
78
-
79
- prd.outf prd.activate(sn)
80
-
81
- end
82
- end
83
- alias_command 'device activate', 'product device activate'
84
-
85
- alias_command 'sn list', 'product device list'
86
- alias_command 'sn enable', 'product device enable'
87
- alias_command 'sn activate', 'product device activate'
88
-
89
- # vim: set ai et sw=2 ts=2 :
@@ -1,45 +0,0 @@
1
- require 'MrMurano/Account'
2
-
3
- command 'product list' do |c|
4
- c.syntax = %{murano product list [options]}
5
- c.description = %{List products}
6
- c.option '--idonly', 'Only return the ids'
7
- c.option '--[no-]all', 'Show all fields'
8
- c.option '-o', '--output FILE', %{Download to file instead of STDOUT}
9
-
10
- c.action do |args, options|
11
- acc = MrMurano::Account.new
12
- data = acc.products
13
-
14
- io=nil
15
- if options.output then
16
- io = File.open(options.output, 'w')
17
- end
18
-
19
- if options.idonly then
20
- headers = [:modelId]
21
- data = data.map{|row| [row[:modelId]]}
22
- elsif not options.all then
23
- headers = [:label, :modelId]
24
- data = data.map{|r| [r[:label], r[:modelId]]}
25
- else
26
- headers = data[0].keys
27
- data = data.map{|r| headers.map{|h| r[h]}}
28
- end
29
-
30
- acc.outf(data, io) do |dd, ios|
31
- if options.idonly then
32
- ios.puts dd.join(' ')
33
- else
34
- acc.tabularize({
35
- :headers=>headers.map{|h| h.to_s},
36
- :rows=>dd
37
- }, ios)
38
- end
39
- end
40
- io.close unless io.nil?
41
-
42
- end
43
- end
44
-
45
- # vim: set ai et sw=2 ts=2 :
@@ -1,27 +0,0 @@
1
- require 'MrMurano/Product'
2
-
3
- command 'product device write' do |c|
4
- c.syntax = %{murano product device write <identifier> <alias> <value> ([<alias> <value>]…)}
5
- c.summary = %{Write values into a device}
6
-
7
- c.action do |args,options|
8
- sn = args.shift
9
- prd = MrMurano::Product.new
10
- if (args.count % 2) != 0 then
11
- prd.error "Last alias is missing a value to write."
12
- else
13
- data = Hash[*args]
14
- ret = prd.write(sn, data)
15
- prd.outf(ret) do |dd|
16
- ret.each_pair do |k,v|
17
- if v == 'ok' then
18
- say "#{k.to_s}: #{v}"
19
- else
20
- prd.error "#{k.to_s}: #{v}"
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
27
- # vim: set ai et sw=2 ts=2 :
@@ -1,41 +0,0 @@
1
-
2
- command 'solution create' do |c|
3
- c.syntax = %{murano solution create <name>}
4
- c.summary = %{Create a new solution}
5
- c.option '--save', %{Save new solution id to config}
6
-
7
- c.action do |args, options|
8
- acc = MrMurano::Account.new
9
- if args.count < 1 then
10
- acc.error "Name of solution missing"
11
- exit 1
12
- end
13
- name = args[0]
14
-
15
- ret = acc.new_solution(name)
16
- if ret.nil? then
17
- acc.error "Create failed"
18
- exit 5
19
- end
20
- if not ret.kind_of?(Hash) and not ret.empty? then
21
- acc.error "Create failed: #{ret.to_s}"
22
- exit 2
23
- end
24
-
25
- # create doesn't return anything, so we need to go look for it.
26
- ret = acc.solutions.select do |i|
27
- i[:type] == 'dataApi' and (i[:name] == name or i[:domain] =~ /#{name}\./i)
28
- end
29
- sid = (ret.first or {})[:apiId]
30
- if sid.nil? or sid.empty? then
31
- acc.error "Didn't find an apiId!!!! #{name} -> #{ret} "
32
- exit 3
33
- end
34
- if options.save then
35
- $cfg.set('solution.id', sid)
36
- end
37
- acc.outf sid
38
-
39
- end
40
- end
41
- # vim: set ai et sw=2 ts=2 :
@@ -1,34 +0,0 @@
1
- require 'MrMurano/Account'
2
-
3
- command 'solution delete' do |c|
4
- c.syntax = %{murano solution delete <solution id>}
5
- c.description = %{Delete a solution}
6
-
7
- c.action do |args, options|
8
- acc = MrMurano::Account.new
9
- if args.count < 1 then
10
- acc.error "Solution id or name missing"
11
- return
12
- end
13
- name = args[0]
14
-
15
-
16
- # Need to convert what we got into the internal PID.
17
- ret = (acc.solutions or []).select{|i| i.has_value?(name) or i[:domain] =~ /#{name}\./ }
18
-
19
- if $cfg['tool.debug'] then
20
- say "Matches found:"
21
- acc.outf ret
22
- end
23
-
24
- if ret.empty? then
25
- acc.error "No solution matching '#{name}' found. Nothing to delete."
26
- else
27
- ret = acc.delete_solution(ret.first[:sid])
28
- if not ret.kind_of?(Hash) and not ret.empty? then
29
- acc.error "Delete failed: #{ret.to_s}"
30
- end
31
- end
32
- end
33
- end
34
- # vim: set ai et sw=2 ts=2 :