optica-client 0.1.1 → 0.1.2
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/README.md +4 -2
- data/lib/optica/client/cli.rb +21 -2
- data/lib/optica/client/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: acc987011dd7c2b81f2ba79e53830647562976ac
|
4
|
+
data.tar.gz: b3752eaf4cb62e5fd27e7067619caa7081e6b3bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74f13d76aafedcee686e023b0915ecba1b0d4decff838ece48668cf84dbb5901d0b8830b9a6e57b02a789bfbb14384777cf97ceee8075b245433b89467bfa7b8
|
7
|
+
data.tar.gz: c7f09d76d19fd0e740ccd591091b6623262435fa109c646b8a92ff14e582c3af554b4c39d5449337b1cc9f15d856b11ce1a8876b64fbcbe9faf11af691942bc3
|
data/README.md
CHANGED
@@ -29,10 +29,12 @@ Usage: optical [options] [FIELD=FILTER] [FIELD2=FILTER2...]
|
|
29
29
|
Options:
|
30
30
|
-s, --select a,b,c Retrieve the given fields, in addition to the defaults
|
31
31
|
-a, --all Retrieve all fields (default is just role,id,hostname)
|
32
|
+
-j, --just a,b,c Print just the given fields as tab-seperated strings,
|
33
|
+
instead of outputting json. Implies selecting those fields.
|
32
34
|
-v, --verbose Print debug information to STDERR
|
33
35
|
-p, --pretty[=false] Pretty-print JSON (default true when STDOUT is a TTY)
|
34
36
|
-r, --refresh Delete cache before performing request.
|
35
|
-
-h, --host URI Optica host (default "https://
|
37
|
+
-h, --host URI Optica host (default "https://example.com")
|
36
38
|
-H, --set-default-host URI Set the default optica host
|
37
39
|
|
38
40
|
Examples:
|
@@ -46,7 +48,7 @@ Examples:
|
|
46
48
|
optical --all launched_by=`whoami`
|
47
49
|
|
48
50
|
SSH into the first matched node:
|
49
|
-
ssh $(optical role=example branch=jake-test | head -n 1
|
51
|
+
ssh $(optical --just hostname role=example branch=jake-test | head -n 1)
|
50
52
|
```
|
51
53
|
|
52
54
|
## Development
|
data/lib/optica/client/cli.rb
CHANGED
@@ -33,6 +33,7 @@ module Optica
|
|
33
33
|
@config = ::Optica::Client::Config.from_file(CONFIG_PATH)
|
34
34
|
@host = nil
|
35
35
|
@fields = []
|
36
|
+
@outs = []
|
36
37
|
@verbose = false
|
37
38
|
@pretty = data_pipe.tty?
|
38
39
|
@cache = ::FileCache.new(
|
@@ -80,6 +81,16 @@ module Optica
|
|
80
81
|
@fields = nil if all
|
81
82
|
end
|
82
83
|
|
84
|
+
o.on(
|
85
|
+
'-j',
|
86
|
+
'--just a,b,c',
|
87
|
+
::Array,
|
88
|
+
'Print just the given fields as tab-seperated strings, instead of outputting json. Implies selecting those fields.'
|
89
|
+
) do |outs|
|
90
|
+
@outs.concat(outs)
|
91
|
+
@fields.concat(outs)
|
92
|
+
end
|
93
|
+
|
83
94
|
o.on(
|
84
95
|
'-v',
|
85
96
|
'--verbose',
|
@@ -133,7 +144,7 @@ module Optica
|
|
133
144
|
optical --all launched_by=`whoami`
|
134
145
|
|
135
146
|
SSH into the first matched node:
|
136
|
-
ssh $(optical role=example branch=jake-test | head -n 1
|
147
|
+
ssh $(optical --just hostname role=example branch=jake-test | head -n 1)
|
137
148
|
EOS
|
138
149
|
end
|
139
150
|
end
|
@@ -161,6 +172,10 @@ module Optica
|
|
161
172
|
return ERR_INVALID
|
162
173
|
end
|
163
174
|
|
175
|
+
if @outs.any? && @verbose
|
176
|
+
ui_pipe.puts "Will print only: #{@outs}"
|
177
|
+
end
|
178
|
+
|
164
179
|
manage_cache
|
165
180
|
|
166
181
|
req = ::Optica::Client::Request.new(host).where(filters)
|
@@ -204,7 +219,11 @@ module Optica
|
|
204
219
|
end
|
205
220
|
|
206
221
|
json.each do |_ip, node|
|
207
|
-
|
222
|
+
if @outs.any?
|
223
|
+
string = node.values_at(*@outs.uniq).join("\t")
|
224
|
+
else
|
225
|
+
string = @pretty ? JSON.pretty_generate(node) : JSON.fast_generate(node)
|
226
|
+
end
|
208
227
|
data_pipe.puts string
|
209
228
|
# easier Ctrl-C in Tmux
|
210
229
|
sleep TTY_TIMEOUT if use_sleep
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: optica-client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jake Teton-Landis
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-05-26 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: filecache
|