hotdog 0.36.0 → 1.20190725.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hotdog/application.rb +39 -35
- data/lib/hotdog/version.rb +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0699880ef57158626ee7638e7cc6266a878006b482254017d13788ce08cf310e'
|
4
|
+
data.tar.gz: a4ac76092f199b6f375c5331ebee107b61f76659a03d101d40c8647989599223
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 71d16dc1aabe0256baa77e107392b97a8e54a10f95859ef50067c7feb3c6004b24bc21cc4b33b87f54718123422d6fcf4c8d413f3b203e794adf566736a64491
|
7
|
+
data.tar.gz: 47d88afa02e2558b7de9b16446a18c0d64d80870fe1bb3f8daa20c5914d485c0dcc13352b2e0512e002d1e58fe0c62bfe783e776f0408c1c663b4e05df49ecd9
|
data/lib/hotdog/application.rb
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
require "erb"
|
4
4
|
require "logger"
|
5
5
|
require "optparse"
|
6
|
+
require "shellwords"
|
6
7
|
require "yaml"
|
7
8
|
require "hotdog/commands"
|
8
9
|
require "hotdog/formatters"
|
@@ -94,14 +95,30 @@ module Hotdog
|
|
94
95
|
args = @optparse.order(argv)
|
95
96
|
|
96
97
|
begin
|
97
|
-
|
98
|
+
if Hash === @options[:source_alias]
|
99
|
+
source_name = @options[:source_alias].fetch(@options[:source], @options[:source])
|
100
|
+
else
|
101
|
+
source_name = @options[:source]
|
102
|
+
end
|
103
|
+
@source_provider = get_source(source_name)
|
98
104
|
rescue NameError
|
99
|
-
STDERR.puts("hotdog: '#{
|
105
|
+
STDERR.puts("hotdog: '#{source_name}' is not a valid hotdog source.")
|
100
106
|
exit(1)
|
101
107
|
end
|
102
108
|
|
103
109
|
begin
|
104
|
-
|
110
|
+
given_command_name = ( args.shift || "help" )
|
111
|
+
if Hash === @options[:command_alias]
|
112
|
+
command_alias = @options[:command_alias].fetch(given_command_name, given_command_name)
|
113
|
+
if Array === command_alias
|
114
|
+
command_name, *command_args = command_alias
|
115
|
+
else
|
116
|
+
command_name, *command_args = Shellwords.shellsplit(command_alias)
|
117
|
+
end
|
118
|
+
else
|
119
|
+
command_name = given_command_name
|
120
|
+
command_args = []
|
121
|
+
end
|
105
122
|
begin
|
106
123
|
command = get_command(command_name)
|
107
124
|
rescue NameError
|
@@ -114,7 +131,7 @@ module Hotdog
|
|
114
131
|
command.define_options(@optparse, @options)
|
115
132
|
|
116
133
|
begin
|
117
|
-
args = command.parse_options(@optparse, args)
|
134
|
+
args = command.parse_options(@optparse, command_args + args)
|
118
135
|
rescue OptionParser::ParseError => error
|
119
136
|
STDERR.puts("hotdog: #{error.message}")
|
120
137
|
command.parse_options(@optparse, ["--help"])
|
@@ -125,7 +142,12 @@ module Hotdog
|
|
125
142
|
options[:headers] = true
|
126
143
|
end
|
127
144
|
|
128
|
-
|
145
|
+
if Hash === @options[:format_alias]
|
146
|
+
format_name = @options[:format_alias].fetch(@options[:format], @options[:format])
|
147
|
+
else
|
148
|
+
format_name = @options[:format]
|
149
|
+
end
|
150
|
+
options[:formatter] = get_formatter(format_name)
|
129
151
|
|
130
152
|
if ( options[:debug] or options[:verbose] ) and ( options[:verbosity] < VERBOSITY_DEBUG )
|
131
153
|
options[:verbosity] = VERBOSITY_DEBUG
|
@@ -260,19 +282,13 @@ module Hotdog
|
|
260
282
|
end
|
261
283
|
|
262
284
|
def get_formatter(name)
|
263
|
-
begin
|
264
|
-
require "hotdog/formatters/#{name}"
|
265
|
-
rescue LoadError => error
|
266
|
-
@logger.info("failed to load library file: #{error}")
|
267
|
-
end
|
268
285
|
begin
|
269
286
|
klass = Hotdog::Formatters.const_get(const_name(name))
|
270
287
|
rescue NameError
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
else
|
288
|
+
begin
|
289
|
+
require "hotdog/formatters/#{name}"
|
290
|
+
klass = Hotdog::Formatters.const_get(const_name(name))
|
291
|
+
rescue LoadError
|
276
292
|
raise(NameError.new("unknown format: #{name}"))
|
277
293
|
end
|
278
294
|
end
|
@@ -280,19 +296,13 @@ module Hotdog
|
|
280
296
|
end
|
281
297
|
|
282
298
|
def get_command(name)
|
283
|
-
begin
|
284
|
-
require "hotdog/commands/#{name}"
|
285
|
-
rescue LoadError => error
|
286
|
-
@logger.info("failed to load library file: #{error}")
|
287
|
-
end
|
288
299
|
begin
|
289
300
|
klass = Hotdog::Commands.const_get(const_name(name))
|
290
301
|
rescue NameError
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
|
295
|
-
else
|
302
|
+
begin
|
303
|
+
require "hotdog/commands/#{name}"
|
304
|
+
klass = Hotdog::Commands.const_get(const_name(name))
|
305
|
+
rescue LoadError
|
296
306
|
raise(NameError.new("unknown command: #{name}"))
|
297
307
|
end
|
298
308
|
end
|
@@ -300,19 +310,13 @@ module Hotdog
|
|
300
310
|
end
|
301
311
|
|
302
312
|
def get_source(name)
|
303
|
-
begin
|
304
|
-
require "hotdog/sources/#{name}"
|
305
|
-
rescue LoadError => error
|
306
|
-
@logger.info("failed to load library file: #{error}")
|
307
|
-
end
|
308
313
|
begin
|
309
314
|
klass = Hotdog::Sources.const_get(const_name(name))
|
310
315
|
rescue NameError
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
|
315
|
-
else
|
316
|
+
begin
|
317
|
+
require "hotdog/sources/#{name}"
|
318
|
+
klass = Hotdog::Sources.const_get(const_name(name))
|
319
|
+
rescue LoadError
|
316
320
|
raise(NameError.new("unknown source: #{name}"))
|
317
321
|
end
|
318
322
|
end
|
data/lib/hotdog/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: hotdog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.20190725.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yamashita Yuu
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-07-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -227,8 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
227
227
|
- !ruby/object:Gem::Version
|
228
228
|
version: '0'
|
229
229
|
requirements: []
|
230
|
-
|
231
|
-
rubygems_version: 2.7.6
|
230
|
+
rubygems_version: 3.0.3
|
232
231
|
signing_key:
|
233
232
|
specification_version: 4
|
234
233
|
summary: Yet another command-line tool for Datadog
|