12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/clandestine/command_line_runner.rb', line 12
def self.run
clo = CommandLineOptions.new
options = clo.parse
command = options.keys.first
value = options[command]
case command
when :add
output = run_command(command, value)
if output
puts "Successfully added password for #{value}"
else
puts "Password already exists for #{value}"
end
when :get
output = run_command(command, value)
if value && !output.is_a?(Array)
IO.copy_to_clipboard(output)
else
IO.print_keys(output)
end
when :update
output = run_command(command, value)
if output
if value
puts "Password for #{value} has been updated"
else
puts "Password for safe has been updated"
end
else
if value
puts "#{value} does not exist"
else
puts "Failed to update safe password"
end
end
when :delete
if run_command(command, value)
puts "#{value} has been deleted"
else
puts "#{value} does not exist"
end
when :remove
if run_command(command, value)
puts "Safe has been successfully removed"
else
puts "Failed to remve safe"
end
when :version
puts Commands.version
when :location
puts Commands.location
when :help
puts clo.parser.on_tail
else
puts clo.parser.on_tail
end
puts
rescue OptionParser::MissingArgument, OptionParser::InvalidOption
puts clo.parser.on_tail
end
|