2pass 1.1.0 → 1.2.0
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/bin/2pass +21 -9
- data/lib/2pass/version.rb +1 -1
- data/lib/2pass.rb +13 -2
- 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: dbffa6c36a23a40c4ec93bc9f0277cf43d3e2388b61459a89aad0bb89458451e
|
4
|
+
data.tar.gz: 5ab72d0c03fb7b718aaec180fdb530755ad69394acb6f808918b978044174e47
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0f0bce6612b408712dac5d313331b8721703f89a4a695ff0d7fd23076d6fcaf7bd2fdec67bdf75c1504f98d59dd400fe04bfa70f729847e234b13ab114d03eb6
|
7
|
+
data.tar.gz: 06d625e2325531c59eff3d197eab64ed3265de9c93ab4046ff39c81f7057ceecb3c2cd640cccc70f9073da3975a3eac9e14fdbaf185242ff4141a0ea1bc6a517
|
data/bin/2pass
CHANGED
@@ -7,7 +7,8 @@ def help_message
|
|
7
7
|
Usage:
|
8
8
|
2pass add <vault_name> <id> <value> - Add new secret
|
9
9
|
2pass get <vault_name> <id> - Get content by ID from the specified vault
|
10
|
-
2pass list <vault_name> - List the content of the specified vault
|
10
|
+
2pass list <vault_name> - List the content of the specified vault as key-value pairs
|
11
|
+
2pass list <vault_name> --json - List the content of the specified vault as JSON
|
11
12
|
2pass link <vault_name> <target_path> - Create a symlink for an existing vault. Useful when the vault is stored in a synced place (iCloud, Dropbox, etc.)
|
12
13
|
2pass -h - Display this help message
|
13
14
|
HELP
|
@@ -23,6 +24,12 @@ OptionParser.new do |opts|
|
|
23
24
|
opts.on("-v", "--version", "Display the version") do
|
24
25
|
options[:version] = true
|
25
26
|
end
|
27
|
+
opts.on("-f", "--format", "Specify output format (e.g., json)") do |format|
|
28
|
+
options[:format] = format == "json" ? :json : :text
|
29
|
+
end
|
30
|
+
opts.on("--json", "Use JSON output format (same as -f json)") do
|
31
|
+
options[:format] = :json
|
32
|
+
end
|
26
33
|
end.parse!
|
27
34
|
|
28
35
|
if options[:help]
|
@@ -43,30 +50,35 @@ end
|
|
43
50
|
command, vault_name, *args = ARGV
|
44
51
|
|
45
52
|
begin
|
46
|
-
case command
|
47
|
-
when
|
53
|
+
case command&.to_sym
|
54
|
+
when :get
|
48
55
|
if args.length < 1
|
49
56
|
help_message
|
50
57
|
exit(1)
|
51
58
|
end
|
52
59
|
id = args[0]
|
53
60
|
puts TwoPass.get_secret(vault_name, id)
|
54
|
-
when
|
61
|
+
when :add
|
55
62
|
if args.length != 2
|
56
63
|
help_message
|
57
64
|
exit(1)
|
58
65
|
end
|
59
66
|
TwoPass.add_secret(vault_name, args[0], args[1])
|
60
|
-
when
|
61
|
-
|
62
|
-
|
67
|
+
when :list
|
68
|
+
if options[:format] == :json
|
69
|
+
puts TwoPass.list_content(vault_name, format: :json)
|
70
|
+
else
|
71
|
+
puts TwoPass.list_content(vault_name)
|
72
|
+
end
|
73
|
+
exit(1)
|
74
|
+
when :link
|
63
75
|
if args.length < 1
|
64
76
|
help_message
|
65
77
|
exit(1)
|
66
78
|
end
|
67
79
|
target_path = args[0]
|
68
80
|
TwoPass.create_symlink(vault_name, target_path)
|
69
|
-
when
|
81
|
+
when :help
|
70
82
|
help_message
|
71
83
|
else
|
72
84
|
help_message
|
@@ -79,5 +91,5 @@ rescue => e
|
|
79
91
|
STDERR.puts e.backtrace
|
80
92
|
end
|
81
93
|
|
82
|
-
exit
|
94
|
+
exit(1)
|
83
95
|
end
|
data/lib/2pass/version.rb
CHANGED
data/lib/2pass.rb
CHANGED
@@ -38,9 +38,20 @@ module TwoPass
|
|
38
38
|
File.write(file_path, YAML.dump(data))
|
39
39
|
end
|
40
40
|
|
41
|
-
def list_content(vault_name)
|
41
|
+
def list_content(vault_name, format: :text)
|
42
42
|
vault = load_vault(vault_name)
|
43
|
-
|
43
|
+
if format == :text
|
44
|
+
vault
|
45
|
+
.map { |h| "#{h[:id]}=#{h[:value]}" }
|
46
|
+
.sort
|
47
|
+
.join("\n")
|
48
|
+
else
|
49
|
+
JSON.pretty_generate(
|
50
|
+
vault
|
51
|
+
.map { |hash| hash.slice(:id, :value) }
|
52
|
+
.sort_by { |hash| hash[:id] }
|
53
|
+
)
|
54
|
+
end
|
44
55
|
end
|
45
56
|
|
46
57
|
def add_secret(vault_name, id, value)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: 2pass
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Olivier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2025-01-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|