jsonip 1.0.0 → 1.0.1
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/jsonip/cli.rb +37 -12
- data/lib/jsonip/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 19daf7e7f93be6b4b9df32fb92c6059d7919b3cf
|
4
|
+
data.tar.gz: 1c8248df2f5e3979fe763629b30ee5fb8fd63290
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c2f0a8cbbf8eb12869257a2c44d40b17b7d7806f4a1b95e7978b750d79a39a80830086265cce5136fa4303771b5c6070c60c37bc797c139b5fb150171f94cb62
|
7
|
+
data.tar.gz: 3ad5c12a70c14f6d57f105ae5e6f624de8ba8dc1b1ca68e5533ee18b024638512fd060e22e6eec46a9d3195d5ed1e42f81bc95a0f8c65722da1e3279a5581a75
|
data/lib/jsonip/cli.rb
CHANGED
@@ -5,24 +5,49 @@ module Jsonip
|
|
5
5
|
class CLI < Thor
|
6
6
|
default_task :copy
|
7
7
|
|
8
|
+
class_option :quiet, type: :boolean, aliases: [ '-q', '-s', '--silent' ], desc: 'Prints minimal output. Useful for shell scripts and pipes'
|
9
|
+
|
10
|
+
desc "print", "Prints your IP, but dont copy"
|
11
|
+
def print
|
12
|
+
say print_message
|
13
|
+
end
|
14
|
+
|
8
15
|
desc "copy", "Copy your IP to clipboard"
|
9
16
|
def copy
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
17
|
+
copy_to_clipboard
|
18
|
+
say copy_message unless options.quiet?
|
19
|
+
end
|
20
|
+
|
21
|
+
protected
|
22
|
+
|
23
|
+
def print_message
|
24
|
+
"".tap do |msg|
|
25
|
+
msg << yellow("Your IP is: ") unless options.quiet?
|
26
|
+
msg << formated_ip
|
16
27
|
end
|
17
28
|
end
|
18
29
|
|
19
|
-
|
30
|
+
def copy_message
|
31
|
+
prefix = yellow("Your IP address")
|
32
|
+
sufix = yellow("was copied to clipboard")
|
33
|
+
|
34
|
+
[ prefix, formated_ip, sufix ].join(" ")
|
35
|
+
end
|
36
|
+
|
37
|
+
def yellow(text)
|
38
|
+
set_color(text, :yellow)
|
39
|
+
end
|
40
|
+
|
41
|
+
def copy_to_clipboard
|
42
|
+
Clipboard.copy json_ip
|
43
|
+
end
|
44
|
+
|
45
|
+
def formated_ip
|
46
|
+
options.quiet? ? json_ip : set_color(json_ip, :white, :bold)
|
47
|
+
end
|
20
48
|
|
21
|
-
def
|
22
|
-
|
23
|
-
ip_text = set_color(ip, :red, :bold)
|
24
|
-
sufix = set_color("was copied to clipboard", :green)
|
25
|
-
[ prefix, ip_text, sufix ].join(" ")
|
49
|
+
def json_ip
|
50
|
+
@json_ip ||= Jsonip.get
|
26
51
|
end
|
27
52
|
end
|
28
53
|
end
|
data/lib/jsonip/version.rb
CHANGED