wavefront-cli 2.5.0 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY.md +6 -1
- data/lib/wavefront-cli/base.rb +23 -1
- data/lib/wavefront-cli/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b7e6e0c9d8fddd6df88fbd3f2f3f8410a74f508627b818b95e5eccaeafdcaf06
|
4
|
+
data.tar.gz: ac3fabdf56be3ce5585802ea5459d66a0a37471171460dd7a30bc22cb07d0992
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a29eb0de9db686d9a4cd4c32beb3c17379a9385fc5532d398af6553aa33406ad06b4637752f5555cc3482f917022ae3ea08f48bc27ff1f4c361048444be1948
|
7
|
+
data.tar.gz: 49d870efddc368949dc08e14da1c740e6200255cb667379918b50ec6ab90dca6b35c2b4bc69226fe2ed55df9a8322c88bedda58081acd31f4d6408306a970d14
|
data/HISTORY.md
CHANGED
@@ -1,6 +1,11 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
-
## 2.
|
3
|
+
## 2.6.0 (27/06/2018)
|
4
|
+
|
5
|
+
* Anything which can be imported can be imported from STDIN. The CLI
|
6
|
+
will do its best to work out if the format is YAML or JSON.
|
7
|
+
|
8
|
+
## 2.5.0 (25/06/2018)
|
4
9
|
|
5
10
|
* Support [derived
|
6
11
|
metrics](https://docs.wavefront.com/derived_metrics.html).
|
data/lib/wavefront-cli/base.rb
CHANGED
@@ -266,7 +266,7 @@ module WavefrontCli
|
|
266
266
|
# Give it a path to a file (as a string) and it will return the
|
267
267
|
# contents of that file as a Ruby object. Automatically detects
|
268
268
|
# JSON and YAML. Raises an exception if it doesn't look like
|
269
|
-
# either.
|
269
|
+
# either. If path is '-' then it will read STDIN.
|
270
270
|
#
|
271
271
|
# @param path [String] the file to load
|
272
272
|
# @return [Hash] a Ruby object of the loaded file
|
@@ -274,6 +274,8 @@ module WavefrontCli
|
|
274
274
|
# @raise pass through any error loading or parsing the file
|
275
275
|
#
|
276
276
|
def load_file(path)
|
277
|
+
return load_from_stdin if path == '-'
|
278
|
+
|
277
279
|
file = Pathname.new(path)
|
278
280
|
raise 'Import file does not exist.' unless file.exist?
|
279
281
|
|
@@ -286,6 +288,26 @@ module WavefrontCli
|
|
286
288
|
end
|
287
289
|
end
|
288
290
|
|
291
|
+
# Read STDIN and return a Ruby object, assuming that STDIN is
|
292
|
+
# valid JSON or YAML. This is a dumb method, it does no
|
293
|
+
# buffering, so STDIN must be a single block of data. This
|
294
|
+
# appears to be a valid assumption for use-cases of this CLI.
|
295
|
+
#
|
296
|
+
# @return [Object]
|
297
|
+
# @raise 'cannot parse stdin' if it, well you know.
|
298
|
+
#
|
299
|
+
def load_from_stdin
|
300
|
+
raw = STDIN.read
|
301
|
+
|
302
|
+
if raw.start_with?('---')
|
303
|
+
YAML.safe_load(raw)
|
304
|
+
else
|
305
|
+
JSON.parse(raw)
|
306
|
+
end
|
307
|
+
rescue
|
308
|
+
raise 'Cannot parse stdin.'
|
309
|
+
end
|
310
|
+
|
289
311
|
# Below here are common methods. Most are used by most classes,
|
290
312
|
# but if they don't match a command described in the docopt
|
291
313
|
# text, the dispatcher will never call them. So, there's no
|
@@ -1 +1 @@
|
|
1
|
-
WF_CLI_VERSION = '2.
|
1
|
+
WF_CLI_VERSION = '2.6.0'.freeze
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wavefront-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Robert Fisher
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-06-
|
11
|
+
date: 2018-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: docopt
|