idcfcloud 0.2.2 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.codeclimate.yml +12 -0
- data/.rubocop.yml +12 -2
- data/README.md +15 -4
- data/idcfcloud.gemspec +7 -8
- data/lib/idcf/cli/command/morio.rb +4 -4
- data/lib/idcf/cli/conf/const.rb +32 -29
- data/lib/idcf/cli/controller/base.rb +50 -23
- data/lib/idcf/cli/controller/cdn.rb +3 -0
- data/lib/idcf/cli/controller/compute.rb +15 -1
- data/lib/idcf/cli/controller/extend/command.rb +25 -2
- data/lib/idcf/cli/controller/extend/search_module.rb +0 -10
- data/lib/idcf/cli/controller/extend/util.rb +12 -0
- data/lib/idcf/cli/controller/include/client.rb +1 -1
- data/lib/idcf/cli/controller/include/command.rb +1 -1
- data/lib/idcf/cli/controller/include/util.rb +3 -5
- data/lib/idcf/cli/controller/include/validate.rb +1 -1
- data/lib/idcf/cli/extend/configure.rb +2 -4
- data/lib/idcf/cli/extend/update.rb +20 -20
- data/lib/idcf/cli/extend/update_file.rb +3 -3
- data/lib/idcf/cli/gem_ext/idcf/json_hyper_schema/expands/link_info_base_extension.rb +25 -9
- data/lib/idcf/cli/gem_ext/thor/init_util.rb +6 -3
- data/lib/idcf/cli/index.rb +17 -5
- data/lib/idcf/cli/lib/api.rb +5 -4
- data/lib/idcf/cli/lib/configure.rb +2 -2
- data/lib/idcf/cli/lib/convert/filter/field_filter.rb +9 -12
- data/lib/idcf/cli/lib/convert/filter/json_path_filter.rb +1 -1
- data/lib/idcf/cli/lib/convert/formatter/base.rb +1 -2
- data/lib/idcf/cli/lib/convert/formatter/csv_format.rb +15 -32
- data/lib/idcf/cli/lib/convert/formatter/json_format.rb +1 -1
- data/lib/idcf/cli/lib/convert/formatter/table_format.rb +2 -2
- data/lib/idcf/cli/lib/convert/formatter/xml_format.rb +1 -1
- data/lib/idcf/cli/lib/convert/helper.rb +16 -5
- data/lib/idcf/cli/lib/document.rb +42 -0
- data/lib/idcf/cli/lib/util/cli_file.rb +1 -1
- data/lib/idcf/cli/lib/util/cli_logger.rb +3 -3
- data/lib/idcf/cli/lib/util/ini_conf.rb +2 -2
- data/lib/idcf/cli/lib/util/input.rb +40 -5
- data/lib/idcf/cli/lib/util/yml_conf.rb +1 -1
- data/lib/idcf/cli/service/base.rb +6 -6
- data/lib/idcf/cli/service/ilb/base_server_for_protocol.rb +22 -18
- data/lib/idcf/cli/validate/custom/month_check_validator.rb +1 -1
- data/lib/idcf/cli/validate/custom/require_relation_validator.rb +2 -2
- data/lib/idcf/cli/validate/define/base.rb +3 -2
- data/lib/idcf/cli/version.rb +1 -1
- metadata +45 -44
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6941bbdef01e10485802468bf365d7d105146ba1
|
4
|
+
data.tar.gz: a32b22a5411de149cf8fd792e5b79c0df512ec89
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 18b046b27be00e1770388bd6067b5d37748a5ed56862e27a5e68cc995fd944a1d15649a5a6206695708f5f61b360b439e1d9c82f210f71c21f892cd78d86e00e
|
7
|
+
data.tar.gz: b1af470e7aac83d807b319e7308851e513541207b9993f65a4cf1ec5bd2047c7640d7bbde2b68c86596ed1731c13afb3a15c5f7726cbda7977ad3b1c91356fa3
|
data/.codeclimate.yml
CHANGED
@@ -12,11 +12,23 @@ engines:
|
|
12
12
|
enabled: true
|
13
13
|
rubocop:
|
14
14
|
enabled: true
|
15
|
+
structure:
|
16
|
+
exclude_paths:
|
17
|
+
- 'test/**/*'
|
15
18
|
ratings:
|
16
19
|
paths:
|
17
20
|
- "**.rb"
|
21
|
+
checks:
|
22
|
+
argument-count:
|
23
|
+
config:
|
24
|
+
threshold: 6
|
25
|
+
method-complexity:
|
26
|
+
config:
|
27
|
+
threshold: 9
|
28
|
+
|
18
29
|
exclude_paths:
|
19
30
|
- vendor/bundle
|
20
31
|
- .idea
|
21
32
|
- bin
|
22
33
|
- doc
|
34
|
+
- output
|
data/.rubocop.yml
CHANGED
@@ -28,7 +28,7 @@ LineLength:
|
|
28
28
|
Exclude:
|
29
29
|
- 'test/**/*'
|
30
30
|
Style/ClassLength:
|
31
|
-
Max:
|
31
|
+
Max: 160
|
32
32
|
Exclude:
|
33
33
|
- 'test/**/*'
|
34
34
|
Style/ModuleLength:
|
@@ -38,4 +38,14 @@ Style/ModuleLength:
|
|
38
38
|
ParameterLists:
|
39
39
|
Max: 6
|
40
40
|
Style/DoubleNegation:
|
41
|
-
Enabled: false
|
41
|
+
Enabled: false
|
42
|
+
Style/SymbolArray:
|
43
|
+
Exclude:
|
44
|
+
- 'test/**/*'
|
45
|
+
Style/IndentHeredoc:
|
46
|
+
EnforcedStyle: active_support
|
47
|
+
Style/PercentLiteralDelimiters:
|
48
|
+
Exclude:
|
49
|
+
- 'test/**/*'
|
50
|
+
Lint/InterpolationCheck:
|
51
|
+
Enabled: false
|
data/README.md
CHANGED
@@ -55,8 +55,9 @@ cat [attributes file path] | echo -e "'"$(cat)"'" | xargs -L1 idcfcloud <service
|
|
55
55
|
| secret-key | | [Configuration file description] | Secret Key |
|
56
56
|
| no-ssl | | | Not using SSL |
|
57
57
|
| no-vssl | | | Not using Verify SSL |
|
58
|
-
| json-path |
|
59
|
-
| fields |
|
58
|
+
| json-path | j | | Narrowing the data part of a return value using json-path<br/>https://github.com/joshbuddy/jsonpath |
|
59
|
+
| fields | f | | Limiting the return value to be displayed (applied only to the latest hash)<br/>Punctuation: comma (",") |
|
60
|
+
| version | | [latest] | The API version to be used |
|
60
61
|
|
61
62
|
|
62
63
|
#### How to Narrow Down (Examples)
|
@@ -75,8 +76,18 @@ idcfcloud your list_billing_history --json-path '$.data[?(@.month=="2017-10")]'
|
|
75
76
|
|
76
77
|
[Your](#your)
|
77
78
|
|
78
|
-
###
|
79
|
-
|
79
|
+
### Common Features
|
80
|
+
|
81
|
+
versions
|
82
|
+
|
83
|
+
Get a supported API version.
|
84
|
+
|
85
|
+
```code
|
86
|
+
$ idcfcloud your versions
|
87
|
+
```
|
88
|
+
|
89
|
+
|
90
|
+
### Compute<a name="compute"></a>
|
80
91
|
|
81
92
|
http://docs.idcf.jp/cloud/api/
|
82
93
|
|
data/idcfcloud.gemspec
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
lib = File.expand_path('../lib', __FILE__)
|
3
2
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
3
|
require 'idcf/cli/version'
|
@@ -31,15 +30,15 @@ Gem::Specification.new do |spec|
|
|
31
30
|
|
32
31
|
spec.add_dependency 'activemodel', '~> 4.2', '>= 4.2.3'
|
33
32
|
spec.add_dependency 'activesupport', '~> 4.2', '>= 4.2.3'
|
34
|
-
spec.add_dependency 'inifile', '~> 3.0', '>= 3.0.0'
|
35
|
-
spec.add_dependency 'thor', '~> 0.19.4'
|
36
33
|
spec.add_dependency 'builder', '~> 3.1'
|
34
|
+
spec.add_dependency 'CFPropertyList', '~> 2.3.5'
|
35
|
+
spec.add_dependency 'facter', '~> 2.5.1'
|
36
|
+
spec.add_dependency 'idcf-faraday_middleware', '~> 0.0.2'
|
37
|
+
spec.add_dependency 'idcf-json_hyper_schema', '~> 0.2.0'
|
38
|
+
spec.add_dependency 'inifile', '~> 3.0', '>= 3.0.0'
|
39
|
+
spec.add_dependency 'jsonpath', '~> 0.8.10'
|
37
40
|
spec.add_dependency 'kosi', '~> 1.0', '>= 1.0.0'
|
38
41
|
|
39
42
|
spec.add_dependency 'open_uri_redirections', '~> 0.2.1'
|
40
|
-
spec.add_dependency '
|
41
|
-
spec.add_dependency 'idcf-faraday_middleware', '~> 0.0.2'
|
42
|
-
spec.add_dependency 'jsonpath', '~> 0.8.10'
|
43
|
-
spec.add_dependency 'facter', '~> 2.5.1'
|
44
|
-
spec.add_dependency 'CFPropertyList', '~> 2.3.5'
|
43
|
+
spec.add_dependency 'thor', '~> 0.19.4'
|
45
44
|
end
|
@@ -11,7 +11,7 @@ module Idcf
|
|
11
11
|
module Command
|
12
12
|
# morio command
|
13
13
|
class Morio
|
14
|
-
MORIO_TXT = <<-
|
14
|
+
MORIO_TXT = <<-TEXT.freeze
|
15
15
|
-+sso+-
|
16
16
|
.... -ssssssso`
|
17
17
|
`-/ossssss+/. `ssssssso`
|
@@ -25,7 +25,7 @@ module Idcf
|
|
25
25
|
./osssssssssssssssssssssss+.
|
26
26
|
`-:+oosssssssssssso+:.
|
27
27
|
``````````
|
28
|
-
|
28
|
+
TEXT
|
29
29
|
ATTRIBUTES_OFF = "\e[0m".freeze
|
30
30
|
MORIO_COLOR = "\e[38;5;45m".freeze
|
31
31
|
TITLE_COLOR = "\e[38;5;45m".freeze
|
@@ -81,7 +81,7 @@ module Idcf
|
|
81
81
|
result << [k.to_s, data.body] if data.success?
|
82
82
|
end
|
83
83
|
end
|
84
|
-
rescue
|
84
|
+
rescue StandardError => _e
|
85
85
|
[]
|
86
86
|
end
|
87
87
|
|
@@ -108,7 +108,7 @@ module Idcf
|
|
108
108
|
if content && content.class == Array && content.size == 2
|
109
109
|
title = content[1].present? ? "#{content[0]} : " : content[0]
|
110
110
|
txt = content[1].present? ? content[1] : ''
|
111
|
-
add_str = format(" #{TITLE_COLOR}
|
111
|
+
add_str = format(" #{TITLE_COLOR}%<title>s#{TEXT_COLOR}%<txt>s", title: title, txt: txt)
|
112
112
|
end
|
113
113
|
"#{base_str}#{add_str}"
|
114
114
|
end
|
data/lib/idcf/cli/conf/const.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'date'
|
2
1
|
require 'logger'
|
3
2
|
require 'idcf/cli/version'
|
4
3
|
module Idcf
|
@@ -6,32 +5,36 @@ module Idcf
|
|
6
5
|
module Conf
|
7
6
|
# const
|
8
7
|
class Const
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
8
|
+
DOCUMENT_URL = 'https://www.idcf.jp/api-docs/'.freeze
|
9
|
+
DOCUMENT_ID_PREFIX = 'reference'.freeze
|
10
|
+
DOCUMENT_ID_SEP = '_'.freeze
|
11
|
+
DOCUMENT_SPACE_CONVERSION = '-'.freeze
|
12
|
+
VERSION_STR = "idcfcloud version #{Idcf::Cli::VERSION}".freeze
|
13
|
+
now = Time.now.strftime('%Y%m%d%H%M%S%6N')
|
14
|
+
dir_path = File.dirname(__FILE__)
|
15
|
+
BASE_PATH = File.expand_path("#{dir_path}/../../../")
|
16
|
+
LOCAL_ERROR_PREFIX = '[idcfcli]'.freeze
|
17
|
+
HEADERS =
|
15
18
|
{
|
16
19
|
'User-Agent': "IDCF CLI v#{Idcf::Cli::VERSION}"
|
17
20
|
}.freeze
|
18
|
-
USER_DIR_PATH
|
19
|
-
VALIDATOR_DIR_PATH
|
20
|
-
CODE_CONF_PATH
|
21
|
-
USER_CONF_PATH
|
22
|
-
USER_CONF_GLOBAL
|
23
|
-
REGIONS
|
24
|
-
GLOBAL_CONF_ITEMS
|
21
|
+
USER_DIR_PATH = '~/.idcfcloud'.freeze
|
22
|
+
VALIDATOR_DIR_PATH = 'idcf/cli/validate/define'.freeze
|
23
|
+
CODE_CONF_PATH = "#{BASE_PATH}/idcf/cli/conf/conf.yml".freeze
|
24
|
+
USER_CONF_PATH = "#{USER_DIR_PATH}/config.ini".freeze
|
25
|
+
USER_CONF_GLOBAL = "#{BASE_PATH}/../config/config.ini".freeze
|
26
|
+
REGIONS = %w[jp-east jp-east-2 jp-west].freeze
|
27
|
+
GLOBAL_CONF_ITEMS =
|
25
28
|
{
|
26
29
|
output_log: {
|
27
30
|
default: 'Y',
|
28
|
-
list: %w
|
31
|
+
list: %w[Y n]
|
29
32
|
},
|
30
33
|
log_path: {
|
31
34
|
default: '~/.idcfcloud/log'
|
32
35
|
}
|
33
36
|
}.freeze
|
34
|
-
USER_CONF_ITEMS
|
37
|
+
USER_CONF_ITEMS =
|
35
38
|
{
|
36
39
|
api_key: nil,
|
37
40
|
secret_key: nil,
|
@@ -39,22 +42,22 @@ module Idcf
|
|
39
42
|
list: REGIONS
|
40
43
|
}
|
41
44
|
}.freeze
|
42
|
-
FULL_HREF_REGEXP
|
43
|
-
CMD_FILE_DIR
|
44
|
-
CMD_FILE_EXT
|
45
|
-
SERVICE_PATH
|
46
|
-
TEMPLATE_DIR
|
47
|
-
OUT_DIR
|
48
|
-
COMP_PATHS
|
45
|
+
FULL_HREF_REGEXP = Regexp.new('\A[a-zA-Z]*:?//').freeze
|
46
|
+
CMD_FILE_DIR = "#{BASE_PATH}/idcf/cli/conf/service".freeze
|
47
|
+
CMD_FILE_EXT = 'json'.freeze
|
48
|
+
SERVICE_PATH = 'idcf/cli/service'.freeze
|
49
|
+
TEMPLATE_DIR = "#{BASE_PATH}/idcf/cli/templates".freeze
|
50
|
+
OUT_DIR = "#{BASE_PATH}/../output".freeze
|
51
|
+
COMP_PATHS = {
|
49
52
|
bash: '~/.bash_profile',
|
50
53
|
zsh: '~/.zprofile'
|
51
54
|
}.freeze
|
52
|
-
LOG_FILE_PREFIX
|
53
|
-
LOG_FILE_NAME
|
54
|
-
LOG_LEVEL
|
55
|
-
CLASSIFY_RULE
|
56
|
-
%w
|
57
|
-
%w
|
55
|
+
LOG_FILE_PREFIX = 'cli_log_'.freeze
|
56
|
+
LOG_FILE_NAME = "#{LOG_FILE_PREFIX}#{now}.log".freeze
|
57
|
+
LOG_LEVEL = Logger::INFO.freeze
|
58
|
+
CLASSIFY_RULE = [
|
59
|
+
%w[sslalgorithms_ids SslalgorithmsIds],
|
60
|
+
%w[dns Dns]
|
58
61
|
].freeze
|
59
62
|
end
|
60
63
|
end
|
@@ -11,6 +11,7 @@ require_relative './extend/init'
|
|
11
11
|
require_relative './include/init'
|
12
12
|
require 'jsonpath'
|
13
13
|
require 'idcf/cli/lib/include/recurring_calling'
|
14
|
+
require 'idcf/cli/lib/document'
|
14
15
|
|
15
16
|
module Idcf
|
16
17
|
module Cli
|
@@ -35,9 +36,13 @@ module Idcf
|
|
35
36
|
class_option :no_vssl,
|
36
37
|
desc: 'not use verify ssl'
|
37
38
|
class_option :json_path,
|
38
|
-
|
39
|
+
aliases: '-j',
|
40
|
+
desc: 'data filter json_path'
|
39
41
|
class_option :fields,
|
40
|
-
|
42
|
+
aliases: '-f',
|
43
|
+
desc: 'field filter'
|
44
|
+
class_option :version,
|
45
|
+
desc: 'api version'
|
41
46
|
|
42
47
|
attr_reader :config, :code_conf, :cmd, :m_classes
|
43
48
|
|
@@ -49,7 +54,11 @@ module Idcf
|
|
49
54
|
attr_accessor :links
|
50
55
|
|
51
56
|
def init(argv)
|
52
|
-
o
|
57
|
+
o = Thor::Options.new(class_options).parse(argv)
|
58
|
+
region = get_region(o)
|
59
|
+
version = service_version(o)
|
60
|
+
Idcf::Cli::Lib::Document.init(region: region, version: version)
|
61
|
+
|
53
62
|
register_schema_method(o)
|
54
63
|
|
55
64
|
make_module_classes.each do |cn, c|
|
@@ -83,28 +92,38 @@ module Idcf
|
|
83
92
|
name.underscore.split('/').last
|
84
93
|
end
|
85
94
|
|
86
|
-
# service version
|
95
|
+
# service version list
|
87
96
|
#
|
88
|
-
# @
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
+
# @return [Array]
|
98
|
+
def service_versions(region)
|
99
|
+
[].tap do |result|
|
100
|
+
sn = service_name
|
101
|
+
Idcf::Cli::Lib::Configure.get_code_conf(sn).each do |k, v|
|
102
|
+
v['region'].each_key do |reg|
|
103
|
+
next unless region == reg
|
104
|
+
result << k
|
105
|
+
break
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
97
109
|
end
|
98
110
|
end
|
99
111
|
|
112
|
+
desc 'versions', 'versions'
|
113
|
+
|
114
|
+
def versions
|
115
|
+
list = self.class.service_versions(self.class.get_region(options))
|
116
|
+
puts make_result_str(make_result_data(list, options), options)
|
117
|
+
end
|
118
|
+
|
100
119
|
protected
|
101
120
|
|
102
121
|
def execute(cmd, *args)
|
103
122
|
data = run(cmd, args, options)
|
104
|
-
puts make_result_str(data,
|
123
|
+
puts make_result_str(data, options)
|
105
124
|
Idcf::Cli::Lib::Util::CliLogger.delete
|
106
125
|
Idcf::Cli::Lib::Util::CliLogger.cleaning(options)
|
107
|
-
rescue => e
|
126
|
+
rescue StandardError => e
|
108
127
|
self.class.error_exit(e)
|
109
128
|
end
|
110
129
|
|
@@ -202,26 +221,34 @@ module Idcf
|
|
202
221
|
|
203
222
|
def make_result_data(data, o)
|
204
223
|
format = output_format(o, '')
|
205
|
-
table_flag = %w
|
224
|
+
table_flag = %w[csv table].include?(format)
|
206
225
|
helper = Idcf::Cli::Lib::Convert::Helper.new
|
207
226
|
|
208
|
-
if helper.filter_target?(o)
|
209
|
-
|
210
|
-
|
211
|
-
result = make_table_data(data)
|
212
|
-
else
|
213
|
-
result = make_base_response
|
214
|
-
result[:data] = data
|
227
|
+
return data_filter(data, o, table_flag) if helper.filter_target?(o)
|
228
|
+
if table_flag
|
229
|
+
return data.class == Hash ? make_table_data(data) : data
|
215
230
|
end
|
231
|
+
result = make_base_response
|
232
|
+
result[:data] = data
|
216
233
|
result
|
217
234
|
end
|
218
235
|
|
236
|
+
def data_filter(data, o, table_flag)
|
237
|
+
helper = Idcf::Cli::Lib::Convert::Helper.new
|
238
|
+
data = make_field_data(data) if helper.only_filter_fields?(o)
|
239
|
+
[Hash, Array].include?(data.class) ? helper.filter(data, o, table_flag) : data
|
240
|
+
end
|
241
|
+
|
219
242
|
# table data
|
220
243
|
# @param data [Hash]
|
221
244
|
# @return Hash
|
222
245
|
def make_table_data(data)
|
223
246
|
data
|
224
247
|
end
|
248
|
+
|
249
|
+
def make_field_data(data)
|
250
|
+
data
|
251
|
+
end
|
225
252
|
end
|
226
253
|
end
|
227
254
|
end
|
@@ -16,7 +16,7 @@ module Idcf
|
|
16
16
|
|
17
17
|
class << self
|
18
18
|
def description
|
19
|
-
'Computeing Service
|
19
|
+
'Computeing Service'
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
@@ -38,6 +38,20 @@ module Idcf
|
|
38
38
|
faraday
|
39
39
|
end
|
40
40
|
|
41
|
+
def make_table_data(data)
|
42
|
+
return data unless data.class == Hash
|
43
|
+
keys = data.keys
|
44
|
+
return data unless keys.count == 2 && keys.include?('count')
|
45
|
+
data.each do |k, v|
|
46
|
+
return v unless k == 'count'
|
47
|
+
end
|
48
|
+
data
|
49
|
+
end
|
50
|
+
|
51
|
+
def make_field_data(data)
|
52
|
+
make_table_data(data)
|
53
|
+
end
|
54
|
+
|
41
55
|
# raise api error msg
|
42
56
|
#
|
43
57
|
# @param res [Faraday::Responce]
|
@@ -1,18 +1,24 @@
|
|
1
1
|
require 'idcf/cli/conf/const'
|
2
2
|
require 'idcf/cli/lib/api'
|
3
|
+
require 'idcf/cli/lib/document'
|
3
4
|
module Idcf
|
4
5
|
module Cli
|
5
6
|
module Controller
|
6
7
|
module Extend
|
7
8
|
# command
|
8
9
|
module Command
|
10
|
+
attr_reader :public_commands
|
11
|
+
|
9
12
|
# register schema method by link
|
10
13
|
#
|
11
14
|
# @param link [Idcf::JsonHyperSchema::Expands::LinkInfoBase]
|
12
15
|
def register_schema_method_by_link!(link)
|
13
|
-
param_str
|
16
|
+
param_str = Idcf::Cli::Lib::Api.command_param_str(link)
|
14
17
|
method_desc = "#{link.title} #{param_str}"
|
15
|
-
|
18
|
+
description = link.description
|
19
|
+
desc method_desc.strip, description
|
20
|
+
description = "#{description}\n\n#{Idcf::Cli::Lib::Document.make_document_desc(link)}"
|
21
|
+
long_desc description
|
16
22
|
define_method link.title.to_sym do |*args|
|
17
23
|
execute(__method__, *args)
|
18
24
|
end
|
@@ -43,6 +49,23 @@ module Idcf
|
|
43
49
|
method_option opn, option
|
44
50
|
end
|
45
51
|
end
|
52
|
+
|
53
|
+
def desc(usage, description, options = {})
|
54
|
+
super(usage, description, options)
|
55
|
+
@public_commands ||= []
|
56
|
+
cmd = usage.split(' ').shift
|
57
|
+
@public_commands << cmd unless @public_commands.include?(cmd)
|
58
|
+
end
|
59
|
+
|
60
|
+
def subcommand_structure
|
61
|
+
result = super
|
62
|
+
list = @public_commands
|
63
|
+
list.concat(superclass.public_commands) if superclass.respond_to?(:public_commands)
|
64
|
+
list.each do |cmd|
|
65
|
+
result[cmd] = nil unless result.key?(cmd)
|
66
|
+
end
|
67
|
+
result
|
68
|
+
end
|
46
69
|
end
|
47
70
|
end
|
48
71
|
end
|
@@ -22,7 +22,6 @@ module Idcf
|
|
22
22
|
def make_module_classes
|
23
23
|
return @m_classes if @m_classes
|
24
24
|
result = {}
|
25
|
-
add_classify_rule
|
26
25
|
|
27
26
|
make_service_paths.each do |fn, path|
|
28
27
|
require path
|
@@ -32,15 +31,6 @@ module Idcf
|
|
32
31
|
@m_classes = result
|
33
32
|
end
|
34
33
|
|
35
|
-
# add classify rule
|
36
|
-
def add_classify_rule
|
37
|
-
Idcf::Cli::Conf::Const::CLASSIFY_RULE.each do |rule|
|
38
|
-
ActiveSupport::Inflector.inflections do |inflect|
|
39
|
-
inflect.irregular(*rule)
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
34
|
# make service paths
|
45
35
|
#
|
46
36
|
# @return Hash
|
@@ -27,6 +27,18 @@ module Idcf
|
|
27
27
|
v = service_version(o)
|
28
28
|
"#{dir}/#{fn}_#{v}_#{region}.#{ext}"
|
29
29
|
end
|
30
|
+
|
31
|
+
# service version
|
32
|
+
#
|
33
|
+
# @param o [Hash]
|
34
|
+
# @return String
|
35
|
+
def service_version(o)
|
36
|
+
versions = service_versions(get_region(o))
|
37
|
+
result = o[:version].nil? ? versions.last : o[:version]
|
38
|
+
msg = "not found input version[#{o[:version]}]"
|
39
|
+
raise Idcf::Cli::Error::CliError, msg unless versions.include?(result)
|
40
|
+
result
|
41
|
+
end
|
30
42
|
end
|
31
43
|
end
|
32
44
|
end
|
@@ -54,7 +54,7 @@ module Idcf
|
|
54
54
|
def faraday_setting(faraday, o)
|
55
55
|
prof = Idcf::Cli::Lib::Configure.get_profile(o)
|
56
56
|
op = {}
|
57
|
-
[
|
57
|
+
%i[api_key secret_key].each do |v|
|
58
58
|
op[v] = o.key?(v) ? o[v] : Idcf::Cli::Lib::Configure.get_user_conf(v.to_s, prof)
|
59
59
|
end
|
60
60
|
faraday.request(faraday_request)
|
@@ -12,10 +12,10 @@ module Idcf
|
|
12
12
|
# @param err_f [Boolean]
|
13
13
|
# @param o [Hash]
|
14
14
|
# @return Stirng
|
15
|
-
def make_result_str(data,
|
15
|
+
def make_result_str(data, o)
|
16
16
|
message = data.class == Hash ? data[:message] : {}
|
17
17
|
f = output_format(o, message)
|
18
|
-
Idcf::Cli::Lib::Convert::Helper.new.format(data,
|
18
|
+
Idcf::Cli::Lib::Convert::Helper.new.format(data, f)
|
19
19
|
end
|
20
20
|
|
21
21
|
# output format
|
@@ -25,9 +25,7 @@ module Idcf
|
|
25
25
|
# @return String
|
26
26
|
def output_format(o, message)
|
27
27
|
default_output = Idcf::Cli::Lib::Configure.get_code_conf('output', o)
|
28
|
-
if message.class == Hash && !message[:output].nil?
|
29
|
-
return default_output
|
30
|
-
end
|
28
|
+
return default_output if message.class == Hash && !message[:output].nil?
|
31
29
|
|
32
30
|
f = o[:output]
|
33
31
|
f.nil? ? default_output : f
|
@@ -25,9 +25,7 @@ module Idcf
|
|
25
25
|
|
26
26
|
def make_profiles(config, o)
|
27
27
|
[].tap do |result|
|
28
|
-
if o[:profile] != 'default' && !check_profile?(config, 'default')
|
29
|
-
result << 'default'
|
30
|
-
end
|
28
|
+
result << 'default' if o[:profile] != 'default' && !check_profile?(config, 'default')
|
31
29
|
result << o[:profile]
|
32
30
|
end
|
33
31
|
end
|
@@ -35,7 +33,7 @@ module Idcf
|
|
35
33
|
def check_profile?(config, name)
|
36
34
|
conf = config[name]
|
37
35
|
return false if conf.nil?
|
38
|
-
Idcf::Cli::Conf::Const::USER_CONF_ITEMS.
|
36
|
+
Idcf::Cli::Conf::Const::USER_CONF_ITEMS.each_key do |k|
|
39
37
|
return false if conf[k.to_s].strip.empty?
|
40
38
|
end
|
41
39
|
true
|