19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/inventarium/cli/push.rb', line 19
def call(args: [], **)
path = args.first || './service.yml'
bar = TTY::ProgressBar.new("Puishing #{path} to inventarium.io [:bar]", total: 30)
bar.advance(10)
config = parse_config(path)
bar.advance(10)
response = push_config(config)
bar.advance(10)
pastel = Pastel.new
case response.code
when '200'
puts "[#{pastel.green('DONE')}]"
exit(0) when '401' puts "[#{pastel.red('FAIL')}] #{response.body}"
when '403' puts "[#{pastel.red('FAIL')}] #{response.body}"
when '422' puts "[#{pastel.red('FAIL')}]"
pp JSON.parse(response.body)
when '500'
puts "[#{pastel.red('FAIL')}] Service error, please try later or create an issue in https://github.com/inventarium-org/core"
end
exit(1)
end
|