Class: Totpc::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/totpc/cli.rb

Overview

command line interpreter

Instance Method Summary collapse

Constructor Details

#initialize(args, local_options, config) ⇒ CLI

Returns a new instance of CLI.



7
8
9
10
# File 'lib/totpc/cli.rb', line 7

def initialize(args, local_options, config)
  @secrets = Secrets.new(Dir.home + '/.totpc')
  super(args, local_options, config)
end

Instance Method Details

#addObject



16
17
18
19
20
21
22
# File 'lib/totpc/cli.rb', line 16

def add
  STDOUT.print 'id: '
  id = STDIN.gets.chomp
  STDOUT.print 'secret: '
  secret = STDIN.gets.chomp
  @secrets.add(id: id, secret: secret)
end

#chpassObject



35
36
37
# File 'lib/totpc/cli.rb', line 35

def chpass
  @secrets.chpass
end

#listObject



31
32
33
# File 'lib/totpc/cli.rb', line 31

def list
  @secrets.list
end


12
13
14
# File 'lib/totpc/cli.rb', line 12

def print
  @secrets.print
end

#removeObject



24
25
26
27
28
29
# File 'lib/totpc/cli.rb', line 24

def remove
  STDOUT.print 'id: '
  id = STDIN.gets.chomp
  STDOUT.print 'remove ' + id + '? y/[n] '
  @secrets.remove(id) if /^[yY]/ =~ STDIN.gets
end