forj 1.0.3 → 1.0.4

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.
data/lib/destroy.rb ADDED
@@ -0,0 +1,97 @@
1
+ #!/usr/bin/env ruby
2
+ # encoding: UTF-8
3
+
4
+ # (c) Copyright 2014 Hewlett-Packard Development Company, L.P.
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+
18
+ require 'highline/import'
19
+ require 'cloud_connection.rb'
20
+ #
21
+ # Destroy module
22
+ #
23
+ module Forj
24
+ # This module provides the behavior to destroy your forge's server(s)
25
+ module Destroy
26
+ def self.destroy(name, options)
27
+ account = Lorj::Account.new(options[:config])
28
+
29
+ # Setting account at runtime layer
30
+ account[:account_name] = options[:account_name] if options[:account_name]
31
+ # Setting account at account layer
32
+ account.ac_load account[:account_name]
33
+
34
+ o_cloud = Forj::CloudConnection.connect(account)
35
+
36
+ o_forge = o_cloud.get(:forge, name)
37
+
38
+ if o_forge[:servers].count > 0
39
+ destroy_server(o_cloud, o_forge, options, account)
40
+ else
41
+ PrcLib.high_level_msg("No server(s) found on forge instance '%s'.\n",
42
+ name)
43
+ end
44
+ end
45
+
46
+ def self.destroy_server(o_cloud, o_forge, options, account)
47
+ if options[:force]
48
+ # Destroy all servers found
49
+ o_cloud.delete(:forge)
50
+ else
51
+ server_list = get_server_list(o_forge)
52
+
53
+ o_server_number = get_server_index(server_list)
54
+
55
+ if o_server_number >= 0 && o_server_number < o_forge[:servers].count
56
+ # Destroy selected server
57
+ account.set(:forge_server, o_forge[:servers][o_server_number][:id])
58
+ o_cloud.delete(:forge)
59
+ end
60
+
61
+ # Destroy all servers found
62
+ o_cloud.delete(:forge) if o_server_number == server_list.index('all')
63
+ # esc
64
+ PrcLib.high_level_msg("No server destroyed on your demand.\n",
65
+ name
66
+ ) if o_server_number == server_list.index('esc')
67
+ end
68
+ end
69
+
70
+ def self.get_server_list(o_forge)
71
+ # Ask the user to get server(s) to destroy
72
+ server_list = []
73
+ index = 0
74
+
75
+ o_forge[:servers].each do |server|
76
+ server_list[index] = server[:name]
77
+ index += 1
78
+ end
79
+
80
+ server_list << 'all'
81
+ server_list << 'esc'
82
+
83
+ server_list
84
+ end
85
+
86
+ def self.get_server_index(server_list)
87
+ say('Select the index of the server you want to destroy')
88
+ value = choose do |q|
89
+ q.choices(*server_list)
90
+ end
91
+
92
+ o_server_number = server_list.index(value)
93
+
94
+ o_server_number
95
+ end
96
+ end
97
+ end
data/lib/forj-settings.rb CHANGED
@@ -15,208 +15,391 @@
15
15
  # limitations under the License.
16
16
 
17
17
  module Forj
18
- module Settings
19
-
20
- def Settings.common_options(options)
21
- PrcLib.set_level(Logger::INFO) if options[:verbose]
22
- PrcLib.set_level(Logger::DEBUG) if options[:debug]
23
- unless options[:lorj_debug].nil?
24
- PrcLib.core_level = options[:lorj_debug].to_i
25
- PrcLib.set_level(Logger::DEBUG)
26
- end
18
+ # This module helps you to setup your forge's account
19
+ module Settings
20
+ def self.common_options(options)
21
+ PrcLib.level = Logger::INFO if options[:verbose]
22
+ PrcLib.level = Logger::DEBUG if options[:debug]
23
+ unless options[:lorj_debug].nil?
24
+ PrcLib.core_level = options[:lorj_debug].to_i
25
+ PrcLib.level = Logger::DEBUG
27
26
  end
28
-
29
- def Settings.account_show_all(oConfig, account_name)
30
- oConfig.set(:account_name, account_name)
31
-
32
- oForjAccount = Lorj::Account.new(oConfig)
33
- oForjAccount.ac_load()
34
- puts "List of account settings for provider '%s': " % [oForjAccount.get(:provider)]
35
- puts "%-15s %-12s :\n------------------------------" % ['key', 'section name']
36
-
37
- oForjAccount.metadata_each { |section, found_key, hValue|
38
- next if Lorj::rhGet(hValue, :readonly)
39
- sDesc = Lorj::rhGet(hValue, :desc)
40
- puts "%-15s %-12s : %s" % [found_key, section, sDesc]
41
- }
42
- puts "\nUse `forj set KeyName=Value -a %s` to set one." % [ account_name]
43
- puts "Use `forj get -a %s` to check current values." % [ account_name]
27
+ end
28
+
29
+ def self.account_show_all(account_name)
30
+ config = Lorj::Account.new
31
+
32
+ config[:account_name] = account_name
33
+
34
+ config.ac_load config[:account_name]
35
+ puts format(
36
+ "List of account settings for provider '%s': ",
37
+ config.get(:provider)
38
+ )
39
+ puts format(
40
+ "%-15s %-12s :\n------------------------------",
41
+ 'key',
42
+ 'section name'
43
+ )
44
+
45
+ config.meta_each do |section, found_key, hValue|
46
+ next if hValue.rh_get(:readonly)
47
+ s_desc = hValue.rh_get(:desc)
48
+ puts format('%-15s %-12s : %s', found_key, section, s_desc)
44
49
  end
45
-
46
- def Settings.config_show_all(oConfig)
47
- puts "List of available FORJ default settings:"
48
- puts "%-15s %-12s :\n------------------------------" % ['key', 'section name']
49
- oConfig.meta_each { |section, found_key, hValue|
50
- next if Lorj::rhGet(hValue, :readonly)
51
- sDesc = Lorj::rhGet(hValue, :desc)
52
- puts "%-15s %-12s : %s" % [found_key, section, sDesc]
53
- }
54
- puts "\nUse `forj set KeyName=Value` to set one. "
55
- puts "Use `forj get` to get current values. "
50
+ puts format(
51
+ "\nUse `forj set KeyName=Value -a %s` to set one.",
52
+ [account_name]
53
+ )
54
+ puts format(
55
+ 'Use `forj get -a %s` to check current values.',
56
+ account_name
57
+ )
58
+ end
59
+
60
+ def self.config_show_all
61
+ config = Lorj::Account.new
62
+ puts 'List of available FORJ default settings:'
63
+ puts format(
64
+ "%-15s %-12s :\n------------------------------",
65
+ 'key',
66
+ 'section name'
67
+ )
68
+ config.meta_each do |section, found_key, hValue|
69
+ next if hValue.rh_get(:readonly)
70
+ s_desc = hValue.rh_get(:desc)
71
+ puts format('%-15s %-12s : %s', found_key, section, s_desc)
56
72
  end
73
+ puts "\nUse `forj set KeyName=Value` to set one. "
74
+ puts 'Use `forj get` to get current values. '
75
+ end
76
+
77
+ def self.validate_account_set(account, account_name, account_key)
78
+ PrcLib.fatal(1,
79
+ "Unable to update protected '%s'. use `forj setup`," \
80
+ ' to update it.',
81
+ account_key) if account.readonly?(account_key)
82
+
83
+ if account.meta_type?(account_key) == :default
84
+ PrcLib.fatal(1, "Unable set '%s' value. To update this one, use forj" \
85
+ ' set %s, WITHOUT -a %s',
86
+ account_key, account_key, account_name)
87
+ end
88
+ end
57
89
 
58
- def Settings.account_set(oConfig, account_name, *p)
59
- bDirty = false
90
+ def self.format_old_key(account, old_value, key_to_set)
91
+ s_bef = 'unset'
60
92
 
61
- oConfig[:account_name] = account_name
93
+ s_bef = format(
94
+ "'%s' (%s)",
95
+ old_value,
96
+ account.exist?(key_to_set)
97
+ ) if account.exist?(key_to_set)
62
98
 
63
- oForjAccount = Lorj::Account.new(oConfig)
64
- oForjAccount.ac_load()
99
+ s_bef
100
+ end
65
101
 
66
- p.flatten!
67
- p.each { | key_val |
68
- mkey_val = key_val.match(/^(.*) *= *(.*)$/)
102
+ def self.format_new_key(_o_forj_account, key_to_set)
103
+ s_aft = 'unset'
69
104
 
70
- PrcLib.fatal(1, "Syntax error. Please set your value like: 'key=value' and retry.") if not mkey_val
105
+ s_aft = format(
106
+ "'%s' (%s)",
107
+ account.get(key_to_set),
108
+ account.exist?(key_to_set)
109
+ ) if account.exist?(key_to_set)
71
110
 
72
- key_to_set = mkey_val[1]
73
- key_value = mkey_val[2]
111
+ s_aft
112
+ end
74
113
 
75
- sBef = "unset"
76
- sAft = "unset"
114
+ def self.account_set(account_name, *p)
115
+ config = Lorj::Account.new
77
116
 
78
- PrcLib.fatal(1, "Unable to update protected '%s'. use `forj setup`, to update it." % key_to_set) if oForjAccount.readonly?(key_to_set)
79
- if oForjAccount.meta_type?(key_to_set) == :default
80
- PrcLib.fatal(1, "Unable set '%s' value. To update this one, use forj set %s, WITHOUT -a %s" % [key_to_set, key_to_set, account_name])
81
- end
117
+ b_dirty = false
82
118
 
83
- full_key = '%s/%s' % [Lorj::Default.get_meta_section(key_to_set), key_to_set]
119
+ config[:account_name] = account_name
84
120
 
85
- old_value = oForjAccount.get(key_to_set)
86
- sBef = "'%s' (%s)" % [old_value, oForjAccount.exist?(key_to_set)] if oForjAccount.exist?(key_to_set)
121
+ config.ac_load config[:account_name]
87
122
 
88
- if old_value == key_value
89
- puts "%-25s: No update" % [full_key]
90
- next
91
- end
92
- bDirty = true
123
+ p.flatten!
124
+ p.each do |key_val|
125
+ mkey_val = valid_key_value?(key_val)
93
126
 
94
- if key_value == ""
95
- oForjAccount.del(key_to_set)
96
- else
97
- oForjAccount.set(key_to_set, key_value)
98
- end
127
+ key_to_set = mkey_val[1]
128
+ key_value = mkey_val[2]
99
129
 
100
- sAft = "'%s' (%s)" % [oForjAccount.get(key_to_set), oForjAccount.exist?(key_to_set)] if oForjAccount.exist?(key_to_set)
101
- puts "%-25s: %s => %s" % [full_key, sBef, ANSI.bold+sAft+ANSI.clear]
102
- }
103
- oForjAccount.ac_save() if bDirty
104
- end
130
+ validate_account_set(config, account_name, key_to_set)
105
131
 
106
- def Settings.config_set(oConfig, *p)
107
- bDirty = false
132
+ full_key = format(
133
+ '%s/%s',
134
+ Lorj::Default.get_meta_auto(key_to_set),
135
+ key_to_set
136
+ )
108
137
 
109
- p.flatten!
110
- p.each { | key_val |
111
- mkey_val = key_val.match(/^(.*) *= *(.*)$/)
138
+ old_value = config.get(key_to_set)
139
+ s_bef = format_old_key(config, old_value, key_to_set)
112
140
 
113
- PrcLib.fatal(1, "Syntax error. Please set your value like: 'key=value' and retry.") if not mkey_val
141
+ if old_value == key_value
142
+ puts format('%-25s: No update', full_key)
143
+ next
144
+ end
145
+ b_dirty = true
114
146
 
115
- key_to_set = mkey_val[1]
116
- key_value = mkey_val[2]
147
+ if key_value == ''
148
+ config.del(key_to_set)
149
+ else
150
+ config.set(key_to_set, key_value)
151
+ end
117
152
 
118
- sBef = "unset"
119
- sAft = "unset"
120
- if Lorj::Default.get_meta_section(key_to_set).nil?
121
- PrcLib.warning("key '%s' is not a recognized default key by forj process. " % key_to_set)
122
- end
153
+ s_aft = format_new_key(config, key_to_set)
123
154
 
124
- old_value = oConfig.get(key_to_set)
125
- sBef = "%s: '%s'" % [oConfig.exist?(key_to_set), oConfig.get(key_to_set)] if oConfig.exist?(key_to_set)
155
+ puts format(
156
+ '%-25s: %s => %s',
157
+ full_key,
158
+ s_bef,
159
+ ANSI.bold + s_aft + ANSI.clear
160
+ )
161
+ end
162
+ config.ac_save if b_dirty
163
+ end
126
164
 
127
- if old_value == key_value
128
- puts "%-15s: No update" % [key_to_set]
129
- next
130
- end
165
+ def self.valid_key_value?(key_val)
166
+ mkey_val = key_val.match(/^(.*) *= *(.*)$/)
131
167
 
132
- bDirty = true
168
+ PrcLib.fatal(
169
+ 1,
170
+ "Syntax error. Please set your value like: 'key=value' and retry."
171
+ ) unless mkey_val
133
172
 
134
- if key_value != ""
135
- oConfig.localSet(key_to_set, key_value)
136
- else
137
- oConfig.localDel(key_to_set)
138
- end
173
+ mkey_val
174
+ end
139
175
 
140
- sAft = "%s: '%s'" % [oConfig.exist?(key_to_set), oConfig.get(key_to_set)] if oConfig.exist?(key_to_set)
141
- puts "%-15s: %s => %s" % [key_to_set, sBef, ANSI.bold+sAft+ANSI.clear]
142
- }
143
- oConfig.saveConfig() if bDirty
144
- end
176
+ def self.valid_key?(key)
177
+ key = key.to_sym if key.is_a?(String)
178
+
179
+ return nil unless key.is_a?(Symbol)
145
180
 
146
- def Settings.account_get_all(oConfig, account_name)
147
- oConfig.set(:account_name, account_name)
148
- oForjAccount = Lorj::Account.new(oConfig)
149
- PrcLib.fatal(1, "Unable to load account '%s'. Not found." % account_name) if not oForjAccount.ac_load
150
-
151
- puts "legend: default = Application defaults, local = Local default config, %s = '%s' account config\n\n" % [account_name, account_name]
152
- puts "%s %-15s(%-7s) %-12s:\n----------------------------------------" % ['U', 'key', 'origin', 'section name']
153
- oForjAccount.metadata_each { | section, mykey, hValue |
154
- key_exist = oForjAccount.exist?(mykey)
155
-
156
- sUpdMsg = '+'
157
- sUpdMsg = ' ' if Lorj::rhGet(hValue, :readonly)
158
-
159
- if key_exist
160
- highlight = ''
161
- highlight = ANSI.bold if key_exist == account_name
162
- highlight = ANSI.bold + ANSI.yellow if key_exist == 'local'
163
- default_key = nil
164
- default_key = " (from default key '%s')" % Lorj::rhGet(hValue, :default) if Lorj::rhExist?(hValue, :default) == 1 and key_exist != account_name
165
- puts "%s %-15s(%s%-7s%s) %-12s: '%s'%s" % [sUpdMsg, mykey, highlight, key_exist, ANSI.clear, section, oForjAccount.get(mykey), default_key]
166
- else
167
- puts "%s %-15s( ) %-12s: unset" % [sUpdMsg, mykey, section]
168
- end
169
- }
170
- puts "\nOn values identified by '+' you can:"
171
- puts "Use `forj set <key>=<value> -a %s` to update account data." % account_name
172
- puts "Or `forj set <key>= -a %s` to restore key default value." % account_name
181
+ if Lorj.defaults.get_meta_auto(key).nil?
182
+ PrcLib.warning("key '%s' is not a recognized default key by forj"\
183
+ ' model. ', key)
173
184
  end
174
185
 
175
- def Settings.config_get_all(oConfig)
176
- puts "legend: default = Application defaults, local = Local default config\n\n"
177
- puts "%s %-15s(%-7s) %-12s:\n----------------------------------------" % ['U', '''key', 'origin', 'section name']
178
-
179
- oConfig.meta_each { |section, found_key, hValue|
180
- sUpdMsg = '+'
181
- sUpdMsg = ' ' if Lorj::rhGet(hValue, :readonly)
182
- found_key = Lorj::rhGet(hValue, :default) if Lorj::rhExist?(hValue, :default) == 1
183
-
184
- where = oConfig.exist?(found_key)
185
- if where
186
- highlight = ''
187
- highlight = ANSI.bold + ANSI.yellow if where == 'local'
188
- puts "%s %-15s(%s%-7s%s) %-12s: '%s'" % [sUpdMsg, found_key, highlight, where, ANSI.clear, section, oConfig.get(found_key) ]
189
- else
190
- puts "%s %-15s( ) %-12s: unset" % [sUpdMsg, found_key, section]
191
- end
192
- }
193
- puts "\nUse 'forj set <key>=<value>' to update defaults on values identified with '+'"
186
+ key
187
+ end
194
188
 
195
- end
189
+ def self.config_set(*p)
190
+ config = Lorj::Account.new
191
+ b_dirty = false
192
+
193
+ p.flatten!
194
+
195
+ p.each do |key_val|
196
+ mkey_val = valid_key_value?(key_val)
197
+
198
+ key_to_set = mkey_val[1]
199
+ key_value = mkey_val[2]
200
+
201
+ s_bef = 'unset'
202
+ s_aft = 'unset'
203
+
204
+ key_to_set = valid_key?(key_to_set)
196
205
 
197
- def Settings.account_get(oConfig, account_name, key)
206
+ old_value = config.get(key_to_set)
207
+ s_bef = format("%s: '%s'", config.where?(key_to_set)[0],
208
+ config.get(key_to_set)) if config.exist?(key_to_set)
198
209
 
199
- oConfig.set(:account_name, account_name)
200
- oForjAccount = Lorj::Account.new(oConfig)
210
+ next if _no_update?(key_to_set, old_value, key_value, config)
201
211
 
202
- PrcLib.fatal(1, "Unable to load account '%s'. Not found." % account_name) if not oForjAccount.ac_load
212
+ b_dirty = true
213
+
214
+ if key_value != ''
215
+ config.local_set(key_to_set, key_value)
216
+ else
217
+ config.local_del(key_to_set)
218
+ end
219
+
220
+ s_aft = format("%s: '%s'", config.where?(key_to_set)[0],
221
+ config.get(key_to_set)) if config.exist?(key_to_set)
222
+
223
+ puts format('%-15s: %s => %s', key_to_set, s_bef, ANSI.bold(s_aft))
224
+ end
225
+ config.save_local_config if b_dirty
226
+ end
227
+
228
+ def self._no_update?(key_to_set, old_value, key_value, config)
229
+ if key_value == '' && config.where?(key_to_set)[0] != 'local'
230
+ puts format('%-15s: No update', key_to_set)
231
+ return true
232
+ end
233
+
234
+ if old_value == key_value
235
+ puts format('%-15s: No update', key_to_set)
236
+ return true
237
+ end
238
+ false
239
+ end
240
+
241
+ def self.format_highlight(account_name, config_where, where_format)
242
+ return format(where_format, config_where) if config_where == 'default'
243
+
244
+ return ANSI.bold(format(where_format,
245
+ account_name)) if config_where == 'account'
246
+ ANSI.bold(ANSI.yellow(format(where_format, config_where)))
247
+ end
248
+
249
+ def self.get_account_values(account, account_name)
250
+ Lorj.defaults.meta_each do |section, mykey, hValue|
251
+ config_where = account.where?(mykey,
252
+ :names => %w(account local default))
253
+
254
+ s_upd_msg = '+'
255
+ s_upd_msg = ' ' if hValue.rh_get(:readonly)
256
+
257
+ if config_where
258
+ where_highlight = format_highlight(account_name,
259
+ config_where[0], '%-7s')
260
+ default_key = nil
261
+ if hValue.rh_exist?(:default) && config_where[0] != 'account'
262
+ default_key = format(" (from default key '%s')",
263
+ hValue.rh_get(:default))
264
+ end
265
+ puts format("%s %-15s(%s) %-12s: '%s'%s",
266
+ s_upd_msg, mykey, where_highlight, section,
267
+ account.get(mykey), default_key)
268
+ else
269
+ puts format(
270
+ '%s %-15s( ) %-12s: unset',
271
+ s_upd_msg,
272
+ mykey,
273
+ section
274
+ )
275
+ end
276
+ end
277
+ end
278
+
279
+ def self.account_get_all(oConfig, account_name)
280
+ oConfig[:account_name] = account_name
281
+
282
+ PrcLib.fatal(1, "Unable to load account '%s'. Not found.",
283
+ account_name) unless oConfig.ac_load oConfig[:account_name]
284
+
285
+ puts format(
286
+ 'legend: default = Application defaults, local = Local' \
287
+ " default config, %s = '%s' account config\n\n",
288
+ account_name,
289
+ account_name)
290
+
291
+ puts format(
292
+ '%s %-15s(%-7s) %-12s:' + "\n" + '--------------------------' \
293
+ '--------------', 'U',
294
+ 'key', 'origin',
295
+ 'section name'
296
+ )
297
+
298
+ get_account_values(oConfig, account_name)
299
+
300
+ puts "\nOn values identified by '+' you can:"
301
+
302
+ puts format(
303
+ 'Use `forj set <key>=<value> -a %s` to update account data.',
304
+ account_name
305
+ )
306
+ puts format(
307
+ 'Or `forj set <key>= -a %s` '\
308
+ 'to restore key default value.',
309
+ account_name
310
+ )
311
+ end
312
+
313
+ def self.config_get_all(oConfig)
314
+ puts 'legend: default = Application defaults, local = Local default' \
315
+ " config\n\n"
316
+ puts format(
317
+ "%s %-19s(%-7s) %-12s:\n-----------------------------------" \
318
+ '-----', 'U',
319
+ '''key', 'origin',
320
+ 'section name'
321
+ )
322
+
323
+ oConfig.meta_each do |section, found_key, hValue|
324
+ s_upd_msg = '+'
325
+ s_upd_msg = ' ' if hValue.rh_get(:readonly)
326
+ found_key = hValue.rh_get(:default) if hValue.rh_exist?(:default)
327
+
328
+ where = oConfig.where?(found_key)
329
+ if where
330
+ where = where[0]
331
+ highlight = ''
332
+ highlight = ANSI.bold + ANSI.yellow if where == 'local'
333
+ puts format(
334
+ "%s %-19s(%s%-7s%s) %-12s: '%s'",
335
+ s_upd_msg,
336
+ found_key,
337
+ highlight,
338
+ where,
339
+ ANSI.clear,
340
+ section,
341
+ oConfig.get(found_key)
342
+ )
343
+ else
344
+ puts format(
345
+ '%s %-19s( ) %-12s: unset',
346
+ s_upd_msg,
347
+ found_key,
348
+ section
349
+ )
350
+ end
351
+ end
352
+ puts "\nUse 'forj set <key>=<value>' to update defaults on values" \
353
+ " identified with '+'"
354
+ end
355
+
356
+ def self.account_get(oConfig, account_name, key)
357
+ oConfig[:account_name] = account_name
358
+
359
+ PrcLib.fatal(1, "Unable to load account '%s'. Not found.",
360
+ account_name) unless oConfig.ac_load oConfig[:account_name]
361
+
362
+ if oConfig.where?(key)
363
+ puts format(
364
+ "%s: '%s'",
365
+ oConfig.where?(key)[0],
366
+ oConfig.get(key)
367
+ )
368
+ elsif oConfig.where?(key.parameterize.underscore.to_sym)
369
+ key_symb = key.parameterize.underscore.to_sym
370
+ puts format(
371
+ "%s: '%s'",
372
+ oConfig.where?(key_symb)[0],
373
+ oConfig.get(key_symb)
374
+ )
375
+ else
376
+ PrcLib.message("key '%s' not found", key)
377
+ end
378
+ end
379
+
380
+ def self.config_get(oConfig, key)
381
+ where = oConfig.where?(key)
382
+ if where
383
+ puts format("%s:'%s'", where[0], oConfig[key])
384
+ else
385
+ PrcLib.message("key '%s' not found", key)
386
+ end
387
+ end
203
388
 
204
- if oForjAccount.exist?(key)
205
- puts "%s: '%s'" % [oForjAccount.exist?(key), oForjAccount.get(key)]
206
- elsif oForjAccount.exist?(key.parameterize.underscore.to_sym)
207
- key_symb = key.parameterize.underscore.to_sym
208
- puts "%s: '%s'" % [oForjAccount.exist?(key_symb), oForjAccount.get(key_symb)]
209
- else
210
- PrcLib.message("key '%s' not found"% [key])
211
- end
389
+ def self.show_settings(options)
390
+ if !options[:account_name]
391
+ config_show_all
392
+ else
393
+ account_show_all(options[:account_name])
212
394
  end
395
+ end
213
396
 
214
- def Settings.config_get(oConfig, key)
215
- if oConfig.exist?(key)
216
- puts "%s:'%s'" % [oConfig.exist?(key), oConfig.get(key)]
217
- else
218
- PrcLib.message("key '%s' not found" % [key])
219
- end
397
+ def self.set_settings(options, p)
398
+ if options[:account_name]
399
+ account_set(options[:account_name], p)
400
+ else
401
+ config_set(p)
220
402
  end
221
- end
403
+ end
404
+ end
222
405
  end