Class: Keystorage::CLI
- Inherits:
-
Thor
- Object
- Thor
- Keystorage::CLI
show all
- Includes:
- Keystorage
- Defined in:
- lib/keystorage/cli.rb
Constant Summary
Constants included
from Keystorage
DEFAULT_FILE, DEFAULT_SECRET
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Keystorage
#decode, #encode, #file, #path, #render, #render_text, #root, #root!, #secret, #sign, #token, #valid?, #write
Class Method Details
.global_option(*params) ⇒ Object
32
33
34
35
36
|
# File 'lib/keystorage/cli.rb', line 32
def global_option *params
@global_options ||= {}
@global_options[params[0]] = params[1]
class_option params[0],params[1]
end
|
.start(given_args = ARGV, config = {}) ⇒ Object
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/keystorage/cli.rb', line 12
def start(given_args = ARGV, config = {})
global_options = []
OptionParser.new do |opt|
@global_options.each { |name,config|
case config[:type]
when :boolean then
opt.on(config[:aliases],"--#{name.to_s}") { |v| global_options << "--#{name.to_s}"}
opt.on(config[:aliases],"--no-#{name.to_s}") { |v| global_options << "--no-#{name.to_s}"}
when :string then
opt.on(config[:aliases],"--#{name.to_s}=VALUE") { |v| global_options << "--#{name.to_s}=#{v}"}
end
}
opt.parse!(given_args)
end
given_args+=global_options
super(given_args,config)
end
|
Instance Method Details
#get(group, key) ⇒ Object
55
56
57
|
# File 'lib/keystorage/cli.rb', line 55
def get(group,key)
puts render(Manager.new(options).get(group,key))
end
|
#groups ⇒ Object
45
46
47
|
# File 'lib/keystorage/cli.rb', line 45
def groups
puts render(Manager.new(options).groups)
end
|
#keys(group) ⇒ Object
50
51
52
|
# File 'lib/keystorage/cli.rb', line 50
def keys(group)
puts render(Manager.new(options).keys(group))
end
|
#password(new_secret = nil) ⇒ Object
66
67
68
69
|
# File 'lib/keystorage/cli.rb', line 66
def password new_secret=nil
Manager.new(options).password(new_secret)
end
|
#set(group, key, value = nil) ⇒ Object
60
61
62
63
|
# File 'lib/keystorage/cli.rb', line 60
def set(group,key,value=nil)
puts render Manager.new(options).set(group,key,value)
end
|