acm 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -1
- data/exe/acm +54 -13
- data/lib/acm/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: 3b36ad4f4d58f49342edd31fad00cd4d69c2dcde572a141dce2954068c88440a
|
4
|
+
data.tar.gz: dfe7d646e1d8e2aae1c7af64d3fa8d68a19eed3a2c7bb7c3895e51e041a73ba8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 51e8e91d68d9e9ba06aece546f37ec08fe45fc1606a5bc2355e70641e9286c94b98f146d5ebe7ae6454434f23e043e8a64065c821808f4430672a8ceccfc8741
|
7
|
+
data.tar.gz: 540d94db6e7c8e2eb0cbbc57450d0efc5a697aab1bf7e9a73662af175f12f7427d03208c1943e96f6ccd0ca8f273e445a679db54ea55c5885c57d8e60ca72165
|
data/README.md
CHANGED
@@ -9,7 +9,7 @@ Install it yourself as:
|
|
9
9
|
|
10
10
|
> gem install acm
|
11
11
|
|
12
|
-
If you using Windows,
|
12
|
+
If you are using Windows, please install ffi gem:
|
13
13
|
|
14
14
|
> gem install ffi
|
15
15
|
|
@@ -90,6 +90,19 @@ And remove account:
|
|
90
90
|
No such account: Gmail
|
91
91
|
|
92
92
|
|
93
|
+
## Special key: login-with
|
94
|
+
|
95
|
+
Special key 'login-with' is reference to other account.
|
96
|
+
|
97
|
+
> acm add SomeWebService
|
98
|
+
(acm) Key? login-with
|
99
|
+
(acm) Value? GitHub
|
100
|
+
(acm) Key? # Enter to exit.
|
101
|
+
|
102
|
+
To track reference, use acm show command with --track option.
|
103
|
+
|
104
|
+
> acm show --track SomeWebService
|
105
|
+
|
93
106
|
## License
|
94
107
|
|
95
108
|
MIT License
|
data/exe/acm
CHANGED
@@ -10,6 +10,7 @@ require 'clipboard'
|
|
10
10
|
class MyCLI < Thor
|
11
11
|
|
12
12
|
DB_FILE = ENV['ACMDB'] || "#{ENV['HOME']}/.accounts"
|
13
|
+
REFERENCE_KEY = "login-with"
|
13
14
|
|
14
15
|
desc "init", "Init database"
|
15
16
|
def init
|
@@ -37,8 +38,21 @@ class MyCLI < Thor
|
|
37
38
|
print "(acm) Key? "
|
38
39
|
key = STDIN.gets.chomp.strip
|
39
40
|
break if key.empty?
|
40
|
-
|
41
|
-
|
41
|
+
if key == "login-with"
|
42
|
+
while true
|
43
|
+
print "(acm) Value? "
|
44
|
+
value = STDIN.gets.chomp.strip
|
45
|
+
ref_account = lookup(value, db)
|
46
|
+
if ref_account
|
47
|
+
break
|
48
|
+
else
|
49
|
+
puts "#{value} not exist."
|
50
|
+
end
|
51
|
+
end
|
52
|
+
else
|
53
|
+
print "(acm) Value? "
|
54
|
+
value = STDIN.gets.chomp.strip
|
55
|
+
end
|
42
56
|
details[key] = value
|
43
57
|
end
|
44
58
|
db << ac
|
@@ -54,30 +68,35 @@ class MyCLI < Thor
|
|
54
68
|
desc "search PATTERN", "Search accounts by PATTERN"
|
55
69
|
def search(target)
|
56
70
|
db = load_db
|
57
|
-
|
58
|
-
accounts
|
59
|
-
|
71
|
+
accounts = search_accounts(target, db)
|
72
|
+
if accounts.empty?
|
73
|
+
puts "Not found: #{target}"
|
74
|
+
else
|
75
|
+
accounts.each{|a| puts a['account'] }
|
76
|
+
end
|
60
77
|
end
|
61
78
|
|
62
79
|
desc "show [options] ACCOUNT", "Show details of ACCOUNT"
|
63
80
|
option :pass, :type => :boolean, :aliases => "-p", :desc => "Show password"
|
64
81
|
option :clip, :type => :boolean, :aliases => "-c", :desc => "Copy password to clipboard"
|
82
|
+
option :track, :type => :boolean, :aliases => "-t", :desc => "Track referred account"
|
65
83
|
def show(target)
|
66
84
|
db = load_db
|
67
85
|
account = lookup(target.encode("utf-8"), db)
|
68
86
|
if account
|
69
87
|
puts "Account: #{account['account']}"
|
70
|
-
account['details']
|
71
|
-
|
72
|
-
|
88
|
+
print_details(account['details'], options[:pass])
|
89
|
+
copy_password(account['details'], options[:clip])
|
90
|
+
if options[:track] && account['details'][REFERENCE_KEY]
|
91
|
+
ref_account = lookup(account['details'][REFERENCE_KEY], db)
|
92
|
+
if ref_account
|
93
|
+
puts "\nReference: #{ref_account['account']}"
|
94
|
+
print_details(ref_account['details'], options[:pass])
|
95
|
+
copy_password(ref_account['details'], options[:clip])
|
73
96
|
else
|
74
|
-
puts "
|
97
|
+
puts "\nReference not found: #{account['details'][REFERENCE_KEY]}"
|
75
98
|
end
|
76
99
|
end
|
77
|
-
if options[:clip]
|
78
|
-
password_key = account['details'].keys.select{|k| /pass/ =~ k}.first
|
79
|
-
Clipboard.copy(account['details'][password_key])
|
80
|
-
end
|
81
100
|
else
|
82
101
|
puts "No such account: #{target}"
|
83
102
|
end
|
@@ -164,6 +183,28 @@ class MyCLI < Thor
|
|
164
183
|
File.open(DB_FILE, "w"){|f| f.puts db.to_yaml }
|
165
184
|
end
|
166
185
|
|
186
|
+
def search_accounts(target, db)
|
187
|
+
pattern = /#{target.encode("utf-8")}/i
|
188
|
+
db.select{|a| pattern =~ a['account'].tr(" ", "") }
|
189
|
+
end
|
190
|
+
|
191
|
+
def print_details(details, pass = false)
|
192
|
+
details.each do |key, val|
|
193
|
+
if /pass/ =~ key && !pass
|
194
|
+
puts " #{key}: ******"
|
195
|
+
else
|
196
|
+
puts " #{key}: #{val}"
|
197
|
+
end
|
198
|
+
end
|
199
|
+
end
|
200
|
+
|
201
|
+
def copy_password(details, clip = false)
|
202
|
+
if clip
|
203
|
+
password_key = details.keys.select{|k| /pass/ =~ k}.first
|
204
|
+
Clipboard.copy(details[password_key])
|
205
|
+
end
|
206
|
+
end
|
207
|
+
|
167
208
|
end # of class MyCLI
|
168
209
|
|
169
210
|
|
data/lib/acm/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- takatoh
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-03-
|
11
|
+
date: 2020-03-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|