haveapi-client 0.26.3 → 0.26.5
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.
- checksums.yaml +4 -4
- data/lib/haveapi/cli/action_state.rb +12 -11
- data/lib/haveapi/cli/cli.rb +13 -3
- data/lib/haveapi/client/action.rb +2 -2
- data/lib/haveapi/client/communicator.rb +2 -6
- data/lib/haveapi/client/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: e1b98aab9f8e937585fa078d6fa5bc38e68f83ed7b70c800dbaa9a0cf1f4ec28
|
|
4
|
+
data.tar.gz: 2df727132132091b6422d8d4dbc858f6911ed21d96b5e82197a7cb43ad955d9c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7baed8b41fd39094bbf765cf6e48d295a7265dd99038cc85a9142a25b34d18369e9676793f396ee5958922d5b0d9a8f7614b41935a4605afb9f35400cef83c6d
|
|
7
|
+
data.tar.gz: b1c00e04bcc29a60b32e6425c880752eb7c367380366a96662cd64d8de8534393fb7b30a4edf2e592796017e3a9ee2d926115fa75c8bf7e6f1e55552c3ce6f26
|
|
@@ -26,9 +26,9 @@ module HaveAPI::CLI
|
|
|
26
26
|
id ||= @id
|
|
27
27
|
|
|
28
28
|
if cancel
|
|
29
|
-
|
|
29
|
+
warn 'Waiting for the action to cancel (hit Ctrl+C to skip)...'
|
|
30
30
|
else
|
|
31
|
-
|
|
31
|
+
warn 'Waiting for the action to complete (hit Ctrl+C to skip)...'
|
|
32
32
|
end
|
|
33
33
|
|
|
34
34
|
last_status = false
|
|
@@ -47,11 +47,11 @@ module HaveAPI::CLI
|
|
|
47
47
|
end
|
|
48
48
|
rescue Interrupt
|
|
49
49
|
@pb && @pb.stop
|
|
50
|
-
|
|
50
|
+
warn
|
|
51
51
|
|
|
52
52
|
cancel_action(timeout: timeout) if can_cancel && !cancel && last_status
|
|
53
53
|
|
|
54
|
-
|
|
54
|
+
warn
|
|
55
55
|
print_help(id)
|
|
56
56
|
exit(false)
|
|
57
57
|
end
|
|
@@ -81,7 +81,7 @@ module HaveAPI::CLI
|
|
|
81
81
|
end
|
|
82
82
|
|
|
83
83
|
if res.is_a?(HaveAPI::Client::Response) && res.ok?
|
|
84
|
-
|
|
84
|
+
warn 'Cancelled'
|
|
85
85
|
exit
|
|
86
86
|
|
|
87
87
|
elsif res
|
|
@@ -102,11 +102,11 @@ module HaveAPI::CLI
|
|
|
102
102
|
def print_help(id = nil)
|
|
103
103
|
id ||= @id
|
|
104
104
|
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
warn 'Run'
|
|
106
|
+
warn " #{$0} action_state show #{id}"
|
|
107
|
+
warn 'or'
|
|
108
|
+
warn " #{$0} action_state wait #{id}"
|
|
109
|
+
warn "to check the action's progress."
|
|
110
110
|
end
|
|
111
111
|
|
|
112
112
|
protected
|
|
@@ -121,7 +121,8 @@ module HaveAPI::CLI
|
|
|
121
121
|
'%t: [%B]'
|
|
122
122
|
end,
|
|
123
123
|
starting_at: state.progress.current,
|
|
124
|
-
autofinish: false
|
|
124
|
+
autofinish: false,
|
|
125
|
+
output: $stderr
|
|
125
126
|
)
|
|
126
127
|
|
|
127
128
|
@pb.title = if state.status
|
data/lib/haveapi/cli/cli.rb
CHANGED
|
@@ -112,7 +112,7 @@ module HaveAPI::CLI
|
|
|
112
112
|
@input_params[:meta] = { includes: includes } if includes
|
|
113
113
|
|
|
114
114
|
begin
|
|
115
|
-
ret = action.execute(@input_params
|
|
115
|
+
ret = action.execute(@input_params)
|
|
116
116
|
rescue HaveAPI::Client::ValidationError => e
|
|
117
117
|
format_errors(action, 'input parameters not valid', e.errors)
|
|
118
118
|
exit(false)
|
|
@@ -508,7 +508,7 @@ module HaveAPI::CLI
|
|
|
508
508
|
|
|
509
509
|
def format_output(action, response, out = $>)
|
|
510
510
|
if @opts[:raw]
|
|
511
|
-
puts JSON.
|
|
511
|
+
puts JSON.pretty_generate(response)
|
|
512
512
|
return
|
|
513
513
|
end
|
|
514
514
|
|
|
@@ -641,12 +641,22 @@ module HaveAPI::CLI
|
|
|
641
641
|
"#{Dir.home}/.haveapi-client.yml"
|
|
642
642
|
end
|
|
643
643
|
|
|
644
|
+
def system_config_path
|
|
645
|
+
'/etc/haveapi-client.yml'
|
|
646
|
+
end
|
|
647
|
+
|
|
644
648
|
def write_config
|
|
645
649
|
File.write(config_path, YAML.dump(@config))
|
|
646
650
|
end
|
|
647
651
|
|
|
648
652
|
def read_config
|
|
649
|
-
|
|
653
|
+
path = if File.exist?(config_path)
|
|
654
|
+
config_path
|
|
655
|
+
elsif File.exist?(system_config_path)
|
|
656
|
+
system_config_path
|
|
657
|
+
end
|
|
658
|
+
|
|
659
|
+
@config = YAML.load_file(path) if path
|
|
650
660
|
end
|
|
651
661
|
|
|
652
662
|
def server_config(url)
|
|
@@ -16,7 +16,7 @@ module HaveAPI::Client
|
|
|
16
16
|
"#<#{self.class.name} @name=#{@name}>"
|
|
17
17
|
end
|
|
18
18
|
|
|
19
|
-
def execute(data
|
|
19
|
+
def execute(data)
|
|
20
20
|
params_arg = {}
|
|
21
21
|
|
|
22
22
|
if input
|
|
@@ -29,7 +29,7 @@ module HaveAPI::Client
|
|
|
29
29
|
params_arg = params.to_api
|
|
30
30
|
end
|
|
31
31
|
|
|
32
|
-
ret = @api.call(self, params_arg
|
|
32
|
+
ret = @api.call(self, params_arg)
|
|
33
33
|
reset
|
|
34
34
|
ret
|
|
35
35
|
end
|
|
@@ -117,7 +117,7 @@ module HaveAPI::Client
|
|
|
117
117
|
end
|
|
118
118
|
end
|
|
119
119
|
|
|
120
|
-
def call(action, params = {}
|
|
120
|
+
def call(action, params = {})
|
|
121
121
|
args = []
|
|
122
122
|
input_namespace = action.input && action.namespace(:input)
|
|
123
123
|
meta = nil
|
|
@@ -164,11 +164,7 @@ module HaveAPI::Client
|
|
|
164
164
|
end
|
|
165
165
|
|
|
166
166
|
if response[:status]
|
|
167
|
-
|
|
168
|
-
ok(JSON.pretty_generate(response[:response]))
|
|
169
|
-
else
|
|
170
|
-
ok(response[:response])
|
|
171
|
-
end
|
|
167
|
+
ok(response[:response])
|
|
172
168
|
|
|
173
169
|
else
|
|
174
170
|
error(response[:message], response[:errors])
|