MuranoCLI 2.2.4 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.agignore +3 -0
- data/.gitignore +18 -1
- data/.rubocop.yml +222 -0
- data/.trustme.sh +185 -0
- data/.trustme.vim +24 -0
- data/Gemfile +23 -4
- data/LICENSE.txt +1 -1
- data/MuranoCLI.gemspec +43 -8
- data/README.markdown +9 -11
- data/Rakefile +187 -143
- data/TODO.taskpaper +2 -2
- data/bin/murano +51 -52
- data/docs/basic_example.rst +436 -0
- data/docs/completions/murano_completion-bash +3484 -0
- data/docs/demo.md +32 -32
- data/docs/develop.rst +391 -0
- data/lib/MrMurano.rb +21 -7
- data/lib/MrMurano/Account.rb +159 -174
- data/lib/MrMurano/Business.rb +381 -0
- data/lib/MrMurano/Config-Migrate.rb +32 -26
- data/lib/MrMurano/Config.rb +407 -128
- data/lib/MrMurano/Content.rb +191 -0
- data/lib/MrMurano/Gateway.rb +489 -0
- data/lib/MrMurano/Keystore.rb +48 -0
- data/lib/MrMurano/Passwords.rb +103 -0
- data/lib/MrMurano/ProjectFile.rb +121 -79
- data/lib/MrMurano/ReCommander.rb +114 -10
- data/lib/MrMurano/Setting.rb +90 -0
- data/lib/MrMurano/Solution-ServiceConfig.rb +89 -45
- data/lib/MrMurano/Solution-Services.rb +461 -166
- data/lib/MrMurano/Solution-Users.rb +70 -31
- data/lib/MrMurano/Solution.rb +372 -13
- data/lib/MrMurano/SolutionId.rb +73 -0
- data/lib/MrMurano/SyncRoot.rb +137 -0
- data/lib/MrMurano/SyncUpDown.rb +594 -284
- data/lib/MrMurano/Webservice-Cors.rb +71 -0
- data/lib/MrMurano/Webservice-Endpoint.rb +234 -0
- data/lib/MrMurano/Webservice-File.rb +193 -0
- data/lib/MrMurano/Webservice.rb +51 -0
- data/lib/MrMurano/commands.rb +18 -15
- data/lib/MrMurano/commands/business.rb +300 -6
- data/lib/MrMurano/commands/completion-bash.erb +166 -0
- data/lib/MrMurano/commands/{zshcomplete.erb → completion-zsh.erb} +0 -0
- data/lib/MrMurano/commands/completion.rb +76 -39
- data/lib/MrMurano/commands/config.rb +108 -44
- data/lib/MrMurano/commands/content.rb +115 -72
- data/lib/MrMurano/commands/cors.rb +29 -14
- data/lib/MrMurano/commands/devices.rb +286 -0
- data/lib/MrMurano/commands/domain.rb +52 -12
- data/lib/MrMurano/commands/gb.rb +24 -9
- data/lib/MrMurano/commands/globals.rb +64 -0
- data/lib/MrMurano/commands/init.rb +377 -155
- data/lib/MrMurano/commands/keystore.rb +92 -82
- data/lib/MrMurano/commands/link.rb +300 -0
- data/lib/MrMurano/commands/login.rb +74 -11
- data/lib/MrMurano/commands/logs.rb +63 -32
- data/lib/MrMurano/commands/mock.rb +57 -29
- data/lib/MrMurano/commands/password.rb +57 -39
- data/lib/MrMurano/commands/postgresql.rb +127 -94
- data/lib/MrMurano/commands/settings.rb +203 -0
- data/lib/MrMurano/commands/show.rb +79 -38
- data/lib/MrMurano/commands/solution.rb +423 -5
- data/lib/MrMurano/commands/solution_picker.rb +547 -0
- data/lib/MrMurano/commands/status.rb +195 -61
- data/lib/MrMurano/commands/sync.rb +78 -39
- data/lib/MrMurano/commands/timeseries.rb +71 -55
- data/lib/MrMurano/commands/tsdb.rb +113 -87
- data/lib/MrMurano/commands/usage.rb +57 -15
- data/lib/MrMurano/hash.rb +100 -10
- data/lib/MrMurano/http.rb +187 -43
- data/lib/MrMurano/makePretty.rb +16 -14
- data/lib/MrMurano/optparse.rb +2178 -0
- data/lib/MrMurano/progress.rb +138 -0
- data/lib/MrMurano/schema/resource-v1.0.0.yaml +32 -0
- data/lib/MrMurano/template/projectFile.murano.erb +16 -13
- data/lib/MrMurano/verbosing.rb +166 -29
- data/lib/MrMurano/version.rb +30 -1
- data/spec/Account-Passwords_spec.rb +21 -4
- data/spec/Account_spec.rb +69 -146
- data/spec/Business_spec.rb +290 -0
- data/spec/ConfigFile_spec.rb +1 -0
- data/spec/ConfigMigrate_spec.rb +12 -8
- data/spec/Config_spec.rb +40 -34
- data/spec/Content_spec.rb +363 -0
- data/spec/GatewayBase_spec.rb +54 -0
- data/spec/GatewayDevice_spec.rb +321 -0
- data/spec/GatewayResource_spec.rb +266 -0
- data/spec/GatewaySettings_spec.rb +120 -0
- data/spec/Http_spec.rb +18 -8
- data/spec/Mock_spec.rb +2 -2
- data/spec/ProjectFile_spec.rb +25 -14
- data/spec/Setting_spec.rb +110 -0
- data/spec/Solution-ServiceConfig_spec.rb +44 -5
- data/spec/Solution-ServiceEventHandler_spec.rb +23 -14
- data/spec/Solution-ServiceModules_spec.rb +47 -37
- data/spec/Solution-UsersRoles_spec.rb +10 -8
- data/spec/Solution_spec.rb +17 -8
- data/spec/SyncRoot_spec.rb +46 -20
- data/spec/SyncUpDown_spec.rb +437 -201
- data/spec/Verbosing_spec.rb +12 -4
- data/spec/{Solution-Cors_spec.rb → Webservice-Cors_spec.rb} +23 -20
- data/spec/{Solution-Endpoint_spec.rb → Webservice-Endpoint_spec.rb} +43 -41
- data/spec/{Solution-File_spec.rb → Webservice-File_spec.rb} +44 -33
- data/spec/Webservice-Setting_spec.rb +89 -0
- data/spec/_workspace.rb +4 -4
- data/spec/cmd_business_spec.rb +9 -4
- data/spec/cmd_common.rb +44 -1
- data/spec/cmd_content_spec.rb +43 -17
- data/spec/cmd_cors_spec.rb +4 -4
- data/spec/cmd_device_spec.rb +61 -16
- data/spec/cmd_domain_spec.rb +29 -6
- data/spec/cmd_init_spec.rb +281 -126
- data/spec/cmd_keystore_spec.rb +3 -3
- data/spec/cmd_link_spec.rb +98 -0
- data/spec/cmd_password_spec.rb +1 -1
- data/spec/cmd_setting_application_spec.rb +260 -0
- data/spec/cmd_setting_product_spec.rb +220 -0
- data/spec/cmd_status_spec.rb +223 -114
- data/spec/cmd_syncdown_spec.rb +115 -35
- data/spec/cmd_syncup_spec.rb +68 -15
- data/spec/cmd_usage_spec.rb +35 -8
- data/spec/fixtures/dumped_config +6 -4
- data/spec/fixtures/gateway_resource_files/resources.notyaml +12 -0
- data/spec/fixtures/gateway_resource_files/resources.yaml +13 -0
- data/spec/fixtures/gateway_resource_files/resources_invalid.yaml +13 -0
- data/spec/fixtures/mrmuranorc_deleted_bob +0 -2
- data/spec/fixtures/product_spec_files/lightbulb.yaml +20 -13
- data/spec/fixtures/{syncable_content → syncable_conflict}/services/devdata.lua +1 -1
- data/spec/fixtures/{syncable_content → syncable_conflict}/services/timers.lua +0 -0
- data/spec/spec_helper.rb +5 -0
- metadata +262 -171
- data/bin/mr +0 -8
- data/lib/MrMurano/Product-1P-Device.rb +0 -145
- data/lib/MrMurano/Product-Resources.rb +0 -205
- data/lib/MrMurano/Product.rb +0 -358
- data/lib/MrMurano/Solution-Cors.rb +0 -47
- data/lib/MrMurano/Solution-Endpoint.rb +0 -191
- data/lib/MrMurano/Solution-File.rb +0 -166
- data/lib/MrMurano/commands/assign.rb +0 -57
- data/lib/MrMurano/commands/businessList.rb +0 -45
- data/lib/MrMurano/commands/product.rb +0 -14
- data/lib/MrMurano/commands/productCreate.rb +0 -39
- data/lib/MrMurano/commands/productDelete.rb +0 -33
- data/lib/MrMurano/commands/productDevice.rb +0 -87
- data/lib/MrMurano/commands/productDeviceIdCmds.rb +0 -89
- data/lib/MrMurano/commands/productList.rb +0 -45
- data/lib/MrMurano/commands/productWrite.rb +0 -27
- data/lib/MrMurano/commands/solutionCreate.rb +0 -41
- data/lib/MrMurano/commands/solutionDelete.rb +0 -34
- data/lib/MrMurano/commands/solutionList.rb +0 -45
- data/spec/ProductBase_spec.rb +0 -113
- data/spec/ProductContent_spec.rb +0 -162
- data/spec/ProductResources_spec.rb +0 -329
- data/spec/Product_1P_Device_spec.rb +0 -202
- data/spec/Product_1P_RPC_spec.rb +0 -175
- data/spec/Product_spec.rb +0 -153
- data/spec/Solution-ServiceDevice_spec.rb +0 -176
- data/spec/cmd_assign_spec.rb +0 -51
@@ -1,102 +1,236 @@
|
|
1
|
+
# Last Modified: 2017.08.18 /coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
1
3
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
c.description = %{Get the status of files
|
4
|
+
# Copyright © 2016-2017 Exosite LLC.
|
5
|
+
# License: MIT. See LICENSE.txt.
|
6
|
+
# vim:tw=0:ts=2:sw=2:et:ai
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
require 'inflecto'
|
9
|
+
require 'MrMurano/verbosing'
|
10
|
+
require 'MrMurano/SyncRoot'
|
9
11
|
|
10
|
-
|
11
|
-
|
12
|
+
# Load options to control which things to sync
|
13
|
+
def cmd_option_syncable_pickers(cmd)
|
14
|
+
MrMurano::SyncRoot.instance.each_option do |short, long, desc|
|
15
|
+
cmd.option short, long, Inflecto.pluralize(desc)
|
16
|
+
end
|
17
|
+
MrMurano::SyncRoot.instance.each_alias_opt do |long, desc|
|
18
|
+
cmd.option long, Inflecto.pluralize(desc)
|
19
|
+
end
|
12
20
|
|
13
|
-
|
21
|
+
cmd.option(
|
22
|
+
'--[no-]nesting',
|
23
|
+
%(Disable support for arranging Lua modules hierarchically)
|
24
|
+
) do |nestation|
|
25
|
+
# This is only called if user specifies switch.
|
26
|
+
$cfg['modules.no-nesting'] = !nestation
|
27
|
+
end
|
28
|
+
end
|
14
29
|
|
30
|
+
def cmd_defaults_syncable_pickers(options)
|
31
|
+
# Weird. The options is a Commander::Command::Options object, but
|
32
|
+
# options.class says nil! Also, you cannot index properties or
|
33
|
+
# even options.send('opt'). But we can just twiddle the raw table.
|
34
|
+
table = options.__hash__
|
35
|
+
MrMurano::SyncRoot.instance.each_alias_sym do |pseudo, pseudo_sym, name, name_sym|
|
36
|
+
unless table[pseudo_sym].nil?
|
37
|
+
if table[name_sym].nil?
|
38
|
+
table[name_sym] = table[pseudo_sym]
|
39
|
+
elsif table[name_sym] != table[pseudo_sym]
|
40
|
+
MrMurano::Verbose.warning("Ignoring --#{pseudo} because --#{name} also specified")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
15
45
|
|
16
|
-
|
46
|
+
command :status do |c|
|
47
|
+
c.syntax = %(murano status [--options] [filters])
|
48
|
+
c.summary = %(Get the status of files)
|
49
|
+
c.description = %(
|
50
|
+
Get the status of files.
|
17
51
|
|
18
|
-
|
19
|
-
|
52
|
+
Compares the local project against what is up in Murano, showing a summary
|
53
|
+
of what things are new or changed.
|
20
54
|
|
21
|
-
|
22
|
-
|
55
|
+
When --diff is passed, for items that have changes, the remote item and
|
56
|
+
local item are passed to a diff tool and that output is included.
|
23
57
|
|
58
|
+
The diff tool and options to it can be set with the config key 'diff.cmd'.
|
24
59
|
|
25
|
-
|
26
|
-
c.option '--all', 'Check everything'
|
60
|
+
Filters allow for selecting a subset of items to check based on patterns.
|
27
61
|
|
28
|
-
|
29
|
-
|
30
|
-
c.option s, l, d
|
31
|
-
end
|
62
|
+
File glob filters can be used to select local files. The glob is compared
|
63
|
+
with the full file path.
|
32
64
|
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
c.option '--[no-]showall', %{List unchanged as well}
|
65
|
+
Each item type also supports specific filters. These always start with #.
|
66
|
+
Endpoints can be selected with a "#<method>#<path glob>" pattern.
|
67
|
+
).gsub(/^ +/, '').strip
|
37
68
|
|
38
|
-
|
39
|
-
|
40
|
-
:grouped => true
|
69
|
+
# Add flag: --type [application|product|all].
|
70
|
+
cmd_add_solntype_pickers(c)
|
41
71
|
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
72
|
+
c.option '--all', 'Check everything'
|
73
|
+
c.option '--[no-]asdown', %(Report as if syncdown instead of syncup)
|
74
|
+
c.option '--[no-]asup', %(Report as if syncup instead of syncdown (default: true))
|
75
|
+
c.option '--[no-]diff', %(For modified items, show a diff)
|
76
|
+
c.option '--[no-]grouped', %(Group all adds, deletes, and mods together)
|
77
|
+
c.option '--[no-]show-all', %(List unchanged as well)
|
78
|
+
c.option '--[no-]show-type', %(Include type of item)
|
79
|
+
cmd_option_syncable_pickers(c)
|
80
|
+
|
81
|
+
c.action do |args, options|
|
82
|
+
# SKIP: c.verify_arg_count!(args)
|
83
|
+
options.default(
|
84
|
+
all: nil,
|
85
|
+
asdown: nil,
|
86
|
+
asup: nil,
|
87
|
+
diff: false,
|
88
|
+
grouped: true,
|
89
|
+
show_all: false,
|
90
|
+
show_type: false,
|
91
|
+
# delete/create/update are not options the user can specify
|
92
|
+
# for status or diff commands; but the SyncUpDown class expects
|
93
|
+
# them.
|
94
|
+
delete: true,
|
95
|
+
create: true,
|
96
|
+
update: true,
|
97
|
+
)
|
98
|
+
cmd_defaults_solntype_pickers(options)
|
99
|
+
cmd_defaults_syncable_pickers(options)
|
100
|
+
|
101
|
+
def fmtr(item, options)
|
102
|
+
if item.key?(:local_path)
|
103
|
+
desc = item[:local_path].relative_path_from(Pathname.pwd).to_s
|
104
|
+
desc = "#{desc}:#{item[:line]}" if item.key?(:line) && item[:line] > 0
|
49
105
|
else
|
50
|
-
item[:synckey]
|
106
|
+
desc = item[:synckey]
|
107
|
+
end
|
108
|
+
return desc unless options.show_type
|
109
|
+
unless item[:pp_desc].to_s.empty? || item[:pp_desc] == item[:synckey]
|
110
|
+
desc += " (#{item[:pp_desc]})"
|
51
111
|
end
|
112
|
+
desc += " [#{item[:method]} #{item[:path]}]" if item[:method] && item[:path]
|
113
|
+
desc
|
52
114
|
end
|
115
|
+
|
116
|
+
def interject(msg)
|
117
|
+
MrMurano::Verbose.whirly_interject { say msg }
|
118
|
+
end
|
119
|
+
|
53
120
|
def pretty(ret, options)
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
ret[:
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
121
|
+
pretty_group_header(
|
122
|
+
ret[:toadd], 'Only on local machine', 'new locally', options.grouped
|
123
|
+
)
|
124
|
+
ret[:toadd].each do |item|
|
125
|
+
interject " + #{item[:pp_type]} #{highlight_chg(fmtr(item, options))}"
|
126
|
+
end
|
127
|
+
|
128
|
+
pretty_group_header(
|
129
|
+
ret[:todel], 'Only on remote server', 'new remotely', options.grouped
|
130
|
+
)
|
131
|
+
ret[:todel].each do |item|
|
132
|
+
interject " - #{item[:pp_type]} #{highlight_del(fmtr(item, options))}"
|
133
|
+
end
|
134
|
+
|
135
|
+
pretty_group_header(
|
136
|
+
ret[:tomod], 'Items that differ', 'that differs', options.grouped
|
137
|
+
)
|
138
|
+
ret[:tomod].each do |item|
|
139
|
+
interject " M #{item[:pp_type]} #{highlight_chg(fmtr(item, options))}"
|
140
|
+
interject item[:diff] if options.diff
|
141
|
+
end
|
142
|
+
|
143
|
+
unless ret[:skipd].empty?
|
144
|
+
pretty_group_header(
|
145
|
+
ret[:skipd], 'Items without a solution', 'without a solution', options.grouped
|
146
|
+
)
|
147
|
+
ret[:skipd].each do |item|
|
148
|
+
interject " - #{item[:pp_type]} #{highlight_del(fmtr(item, options))}"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
return unless options.show_all
|
153
|
+
interject 'Unchanged:' if options.grouped
|
154
|
+
ret[:unchg].each { |item| interject " #{item[:pp_type]} #{fmtr(item, options)}" }
|
155
|
+
end
|
156
|
+
|
157
|
+
def pretty_group_header(group, header_any, header_empty, grouped)
|
158
|
+
return unless grouped
|
159
|
+
if !group.empty?
|
160
|
+
interject "#{header_any}:"
|
161
|
+
else
|
162
|
+
interject "Nothing #{header_empty}"
|
66
163
|
end
|
67
164
|
end
|
68
165
|
|
69
|
-
|
70
|
-
|
71
|
-
|
166
|
+
def highlight_chg(msg)
|
167
|
+
Rainbow(msg).green.bright
|
168
|
+
end
|
169
|
+
|
170
|
+
def highlight_del(msg)
|
171
|
+
Rainbow(msg).red.bright
|
172
|
+
end
|
173
|
+
|
174
|
+
@grouped = { toadd: [], todel: [], tomod: [], unchg: [], skipd: [] }
|
175
|
+
def gmerge(ret, type, desc, options)
|
176
|
+
if options.grouped
|
72
177
|
out = @grouped
|
73
178
|
else
|
74
|
-
out = {:
|
179
|
+
out = { toadd: [], todel: [], tomod: [], unchg: [], skipd: [] }
|
75
180
|
end
|
76
181
|
|
77
|
-
[
|
182
|
+
%i[toadd todel tomod unchg skipd].each do |kind|
|
78
183
|
ret[kind].each do |item|
|
79
184
|
item = item.to_h
|
80
185
|
item[:pp_type] = type
|
186
|
+
item[:pp_desc] = desc
|
81
187
|
out[kind] << item
|
82
188
|
end
|
83
189
|
end
|
84
190
|
|
85
|
-
unless options.grouped
|
86
|
-
|
191
|
+
pretty(out, options) unless options.grouped
|
192
|
+
end
|
193
|
+
|
194
|
+
# *** Method code starts here ***
|
195
|
+
|
196
|
+
# Check that user doesn't try to asdown and asup, or no-asdown and no-asup.
|
197
|
+
if options.asdown.nil? && options.asup.nil?
|
198
|
+
options.asdown = false
|
199
|
+
options.asup = true
|
200
|
+
elsif !options.asdown.nil? && !options.asup.nil?
|
201
|
+
unless options.asdown ^ options.asup
|
202
|
+
error('Please specify either --asdown or --asup, but not both!')
|
203
|
+
exit 1
|
87
204
|
end
|
205
|
+
elsif options.asdown.nil?
|
206
|
+
options.asdown = !options.asup
|
207
|
+
elsif options.asup.nil?
|
208
|
+
options.asup = !options.asdown
|
209
|
+
else
|
210
|
+
raise('Unexpected code path.')
|
88
211
|
end
|
89
212
|
|
90
|
-
MrMurano::SyncRoot.each_filtered(options.__hash__) do |
|
91
|
-
|
92
|
-
|
93
|
-
|
213
|
+
MrMurano::SyncRoot.instance.each_filtered(options.__hash__) do |_name, type, klass, desc|
|
214
|
+
MrMurano::Verbose.whirly_msg "Fetching #{Inflecto.pluralize(desc)}..."
|
215
|
+
begin
|
216
|
+
syncable = klass.new
|
217
|
+
rescue MrMurano::ConfigError => err
|
218
|
+
MrMurano::Verbose.error "Could not fetch status for #{desc}: #{err}"
|
219
|
+
rescue StandardError => _err
|
220
|
+
raise
|
221
|
+
else
|
222
|
+
ret = syncable.status(options, args)
|
223
|
+
gmerge(ret, type, desc, options)
|
224
|
+
end
|
94
225
|
end
|
226
|
+
MrMurano::Verbose.whirly_stop
|
95
227
|
|
96
228
|
pretty(@grouped, options) if options.grouped
|
97
229
|
end
|
98
230
|
end
|
231
|
+
alias_command 'diff', 'status', '--diff', '--no-grouped'
|
232
|
+
alias_command 'diff application', 'status', '--diff', '--no-grouped', '--type', 'application'
|
233
|
+
alias_command 'diff product', 'status', '--diff', '--no-grouped', '--type', 'product'
|
234
|
+
alias_command 'application diff', 'status', '--diff', '--no-grouped', '--type', 'application'
|
235
|
+
alias_command 'product diff', 'status', '--diff', '--no-grouped', '--type', 'product'
|
99
236
|
|
100
|
-
alias_command :diff, :status, '--diff', '--no-grouped'
|
101
|
-
|
102
|
-
# vim: set ai et sw=2 ts=2 :
|
@@ -1,60 +1,99 @@
|
|
1
|
+
# Last Modified: 2017.08.16 /coding: utf-8
|
2
|
+
# frozen_string_literal: true
|
1
3
|
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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/verbosing'
|
9
|
+
require 'MrMurano/SyncRoot'
|
10
|
+
require 'MrMurano/commands/status'
|
11
|
+
|
12
|
+
def sync_add_options(c, locale)
|
13
|
+
c.option '--[no-]delete', %(Don't delete things from #{locale})
|
14
|
+
c.option '--[no-]create', %(Don't create things on #{locale})
|
15
|
+
c.option '--[no-]update', %(Don't update things on #{locale})
|
16
|
+
end
|
6
17
|
|
7
|
-
|
8
|
-
|
9
|
-
|
18
|
+
def syncdown_files(options, args=nil)
|
19
|
+
args = [] if args.nil?
|
20
|
+
num_synced = 0
|
21
|
+
MrMurano::SyncRoot.instance.each_filtered(options) do |_name, _type, klass, desc|
|
22
|
+
MrMurano::Verbose.whirly_msg "Syncing #{Inflecto.pluralize(desc)}..."
|
23
|
+
sol = klass.new
|
24
|
+
num_synced += sol.syncdown(options, args)
|
10
25
|
end
|
26
|
+
MrMurano::Verbose.whirly_stop
|
27
|
+
num_synced
|
28
|
+
end
|
11
29
|
|
12
|
-
|
13
|
-
c.
|
14
|
-
c.
|
30
|
+
command :syncdown do |c|
|
31
|
+
c.syntax = %(murano syncdown [--options] [filters])
|
32
|
+
c.summary = %(Sync project down from Murano)
|
33
|
+
c.description = %(
|
34
|
+
Sync project down from Murano.
|
35
|
+
).strip
|
15
36
|
|
16
|
-
|
17
|
-
c
|
18
|
-
c.example %{Only Pull new static files}, %{murano syncdown --files --no-delete --no-update}
|
37
|
+
# Add flag: --type [application|product|all].
|
38
|
+
cmd_add_solntype_pickers(c)
|
19
39
|
|
20
|
-
c.
|
21
|
-
|
40
|
+
c.option '--all', 'Sync everything'
|
41
|
+
cmd_option_syncable_pickers(c)
|
42
|
+
sync_add_options(c, 'local machine')
|
22
43
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
44
|
+
c.example %(Make local be like what is on the server), %(murano syncdown --all)
|
45
|
+
c.example %(Pull down new things, but don't delete or modify anything), %(murano syncdown --all --no-delete --no-update)
|
46
|
+
c.example %(Only Pull new static files), %(murano syncdown --files --no-delete --no-update)
|
47
|
+
|
48
|
+
c.action do |args, options|
|
49
|
+
# SKIP: c.verify_arg_count!(args)
|
50
|
+
options.default(delete: true, create: true, update: true)
|
51
|
+
cmd_defaults_solntype_pickers(options)
|
52
|
+
cmd_defaults_syncable_pickers(options)
|
53
|
+
syncdown_files(options.__hash__, args)
|
27
54
|
end
|
28
55
|
end
|
29
|
-
alias_command
|
56
|
+
alias_command 'pull', 'syncdown', '--no-delete'
|
57
|
+
alias_command 'pull application', 'syncdown', '--no-delete', '--type', 'application'
|
58
|
+
alias_command 'pull product', 'syncdown', '--no-delete', '--type', 'product'
|
59
|
+
alias_command 'application pull', 'syncdown', '--no-delete', '--type', 'application'
|
60
|
+
alias_command 'product pull', 'syncdown', '--no-delete', '--type', 'product'
|
30
61
|
|
31
62
|
command :syncup do |c|
|
32
|
-
c.syntax = %
|
33
|
-
c.
|
34
|
-
c.
|
63
|
+
c.syntax = %(murano syncup [--options] [filters])
|
64
|
+
c.summary = %(Sync project up into Murano)
|
65
|
+
c.description = %(
|
66
|
+
Sync project up into Murano.
|
67
|
+
).strip
|
35
68
|
|
36
|
-
#
|
37
|
-
|
38
|
-
c.option s, l, d
|
39
|
-
end
|
40
|
-
|
41
|
-
c.option '--[no-]delete', %{Don't delete things from server}
|
42
|
-
c.option '--[no-]create', %{Don't create things on server}
|
43
|
-
c.option '--[no-]update', %{Don't update things on server}
|
69
|
+
# Add flag: --type [application|product|all].
|
70
|
+
cmd_add_solntype_pickers(c)
|
44
71
|
|
45
|
-
c.
|
46
|
-
c
|
47
|
-
c
|
72
|
+
c.option '--all', 'Sync everything'
|
73
|
+
cmd_option_syncable_pickers(c)
|
74
|
+
sync_add_options(c, 'server')
|
48
75
|
|
49
|
-
c.
|
50
|
-
|
76
|
+
c.example %(Deploy project to server), %(murano syncup --all)
|
77
|
+
c.example %(Update static files), %(murano syncup --files)
|
78
|
+
c.example %(Only add or modify static files), %(murano syncup --files --no-delete)
|
51
79
|
|
52
|
-
|
80
|
+
c.action do |args, options|
|
81
|
+
# SKIP: c.verify_arg_count!(args)
|
82
|
+
options.default(delete: true, create: true, update: true)
|
83
|
+
cmd_defaults_solntype_pickers(options)
|
84
|
+
cmd_defaults_syncable_pickers(options)
|
85
|
+
#MrMurano::Verbose.whirly_start "Syncing solutions..."
|
86
|
+
MrMurano::SyncRoot.instance.each_filtered(options.__hash__) do |_name, _type, klass, desc|
|
87
|
+
MrMurano::Verbose.whirly_msg "Syncing #{Inflecto.pluralize(desc)}..."
|
53
88
|
sol = klass.new
|
54
89
|
sol.syncup(options, args)
|
55
90
|
end
|
91
|
+
MrMurano::Verbose.whirly_stop
|
56
92
|
end
|
57
93
|
end
|
58
|
-
alias_command
|
94
|
+
alias_command 'push', 'syncup', '--no-delete'
|
95
|
+
alias_command 'push application', 'syncup', '--no-delete', '--type', 'application'
|
96
|
+
alias_command 'push product', 'syncup', '--no-delete', '--type', 'product'
|
97
|
+
alias_command 'application push', 'syncup', '--no-delete', '--type', 'application'
|
98
|
+
alias_command 'product push', 'syncup', '--no-delete', '--type', 'product'
|
59
99
|
|
60
|
-
# vim: set ai et sw=2 ts=2 :
|
@@ -1,109 +1,127 @@
|
|
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 'csv'
|
9
|
+
require 'MrMurano/ReCommander'
|
2
10
|
require 'MrMurano/Solution-ServiceConfig'
|
3
11
|
|
4
12
|
module MrMurano
|
5
13
|
class Timeseries < ServiceConfig
|
6
|
-
def initialize
|
14
|
+
def initialize(sid=nil)
|
15
|
+
# FIXME/2017-07-03: What soln types have timeseries?
|
16
|
+
@solntype = 'application.id'
|
7
17
|
super
|
8
|
-
@
|
18
|
+
@service_name = 'timeseries'
|
9
19
|
end
|
10
20
|
|
11
21
|
def query(query)
|
12
|
-
call(:query, :post,
|
22
|
+
call(:query, :post, q: query)
|
13
23
|
end
|
14
24
|
|
15
25
|
def write(writestr)
|
16
|
-
call(:write, :post,
|
26
|
+
call(:write, :post, query: writestr)
|
17
27
|
end
|
18
28
|
|
19
29
|
def command(cmd)
|
20
|
-
call(:command, :post,
|
30
|
+
call(:command, :post, q: cmd)
|
21
31
|
end
|
22
|
-
|
23
32
|
end
|
24
33
|
end
|
25
34
|
|
26
35
|
command :timeseries do |c|
|
27
|
-
c.syntax = %
|
28
|
-
c.summary = %
|
29
|
-
c.description = %
|
36
|
+
c.syntax = %(murano timeseries)
|
37
|
+
c.summary = %(About Timeseries)
|
38
|
+
c.description = %(
|
39
|
+
These commands are deprecated.
|
30
40
|
|
31
41
|
The timeseries sub-commands let you interact directly with the Timeseries
|
32
|
-
instance in a solution.
|
33
|
-
quickly try out different queries or write test data.
|
42
|
+
instance in a solution. This allows for easier debugging, being able to
|
43
|
+
quickly try out different queries or write test data.
|
44
|
+
).strip
|
34
45
|
|
35
|
-
c.action do |
|
46
|
+
c.action do |_args, _options|
|
36
47
|
::Commander::UI.enable_paging
|
37
48
|
say MrMurano::SubCmdGroupHelp.new(c).get_help
|
38
49
|
end
|
39
50
|
end
|
40
51
|
|
41
52
|
command 'timeseries query' do |c|
|
42
|
-
c.syntax = %
|
43
|
-
c.summary = %
|
44
|
-
c.description = %
|
53
|
+
c.syntax = %(murano timeseries query <query string>)
|
54
|
+
c.summary = %(Query the timeseries database)
|
55
|
+
c.description = %(
|
56
|
+
This command is deprecated.
|
45
57
|
|
46
|
-
Query the timeseries database
|
47
|
-
|
48
|
-
c.option '
|
49
|
-
c.option '--[no-]
|
58
|
+
Query the timeseries database.
|
59
|
+
).strip
|
60
|
+
c.option '-o', '--output FILE', %(Download to file instead of STDOUT)
|
61
|
+
c.option '--[no-]json', %(Display results as raw json)
|
62
|
+
c.option '--[no-]csv', %(Display results as CSV)
|
50
63
|
|
51
|
-
c.action do |args,options|
|
52
|
-
|
64
|
+
c.action do |args, options|
|
65
|
+
# SKIP: c.verify_arg_count!(args)
|
66
|
+
options.defalts json: false, csv: false
|
53
67
|
sol = MrMurano::Timeseries.new
|
54
68
|
ret = sol.query args.join(' ')
|
55
69
|
|
56
70
|
$cfg['tool.outformat'] = 'json' if options.json
|
57
71
|
$cfg['tool.outformat'] = 'best csv' if options.csv
|
58
72
|
|
59
|
-
io=
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
}, ios)
|
73
|
+
io = File.open(options.output, 'w') if options.output
|
74
|
+
sol.outf(ret, io) do |_dd, ios|
|
75
|
+
(ret[:results] || []).each do |res|
|
76
|
+
(res[:series] || []).each do |ser|
|
77
|
+
sol.tabularize(
|
78
|
+
{
|
79
|
+
title: ser[:name],
|
80
|
+
headers: ser[:columns],
|
81
|
+
rows: ser[:values],
|
82
|
+
},
|
83
|
+
ios
|
84
|
+
)
|
72
85
|
end
|
73
86
|
end
|
74
87
|
end
|
75
88
|
io.close unless io.nil?
|
76
|
-
|
77
89
|
end
|
78
90
|
end
|
79
|
-
alias_command
|
91
|
+
alias_command 'tsq', 'timeseries query'
|
80
92
|
|
81
93
|
command 'timeseries write' do |c|
|
82
|
-
c.syntax = %
|
83
|
-
c.summary = %
|
84
|
-
c.description = %
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
94
|
+
c.syntax = %(murano timeseries <write string>)
|
95
|
+
c.summary = %(Write data into the timeseries database)
|
96
|
+
c.description = %(
|
97
|
+
This command is deprecated.
|
98
|
+
|
99
|
+
Write data into the timeseries database.
|
100
|
+
).strip
|
101
|
+
c.option '--[no-]json', %(Display results as raw json)
|
102
|
+
c.action do |args, options|
|
103
|
+
c.verify_arg_count!(args)
|
104
|
+
options.defalts(json: false)
|
90
105
|
$cfg['tool.outformat'] = 'json' if options.json
|
91
106
|
sol = MrMurano::Timeseries.new
|
92
107
|
ret = sol.write args.join(' ')
|
93
108
|
sol.outf ret
|
94
109
|
end
|
95
110
|
end
|
96
|
-
alias_command
|
111
|
+
alias_command 'tsw', 'timeseries write'
|
97
112
|
|
98
113
|
command 'timeseries command' do |c|
|
99
|
-
c.syntax = %
|
100
|
-
c.summary = %
|
101
|
-
c.description = %
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
114
|
+
c.syntax = %(murano timeseries command <db command>)
|
115
|
+
c.summary = %(Execute a non-query command in the database)
|
116
|
+
c.description = %(
|
117
|
+
This command is deprecated.
|
118
|
+
|
119
|
+
Execute a non-query command in the database.
|
120
|
+
).strip
|
121
|
+
c.option '--[no-]json', %(Display results as raw json)
|
122
|
+
c.action do |args, options|
|
123
|
+
# SKIP: c.verify_arg_count!(args)
|
124
|
+
options.defalts(json: false)
|
107
125
|
$cfg['tool.outformat'] = 'json' if options.json
|
108
126
|
sol = MrMurano::Timeseries.new
|
109
127
|
ret = sol.command args.join(' ')
|
@@ -111,5 +129,3 @@ Execute a non-query command in the database}
|
|
111
129
|
end
|
112
130
|
end
|
113
131
|
|
114
|
-
|
115
|
-
# vim: set ai et sw=2 ts=2 :
|