mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-23 13:57:52 +00:00
add interactive mode
This commit is contained in:
parent
c12c370b42
commit
548a1e8fcc
2 changed files with 53 additions and 2 deletions
50
lib/Cli.rb
50
lib/Cli.rb
|
@ -226,4 +226,54 @@ class Cli
|
|||
end
|
||||
end
|
||||
|
||||
# Interactive mode
|
||||
def interactive()
|
||||
while true
|
||||
command = ask("<mpw> ").split(' ')
|
||||
|
||||
case command[0]
|
||||
when 'display', 'show', 'd', 's'
|
||||
if !command[1].nil? && !command[1].empty?
|
||||
display(command[1], command[2])
|
||||
end
|
||||
when 'add', 'a'
|
||||
cli.add()
|
||||
when 'update', 'u'
|
||||
if !command[1].nil? && !command[1].empty?
|
||||
update(command[1])
|
||||
end
|
||||
when 'remove', 'delete', 'r', 'd'
|
||||
if !command[1].nil? && !command[1].empty?
|
||||
remove(command[1])
|
||||
end
|
||||
when 'help', 'h', '?'
|
||||
puts '# Help'
|
||||
puts '# --------------------'
|
||||
puts '# Display an item:'
|
||||
puts '# display SEARCH'
|
||||
puts '# show SEARCH'
|
||||
puts '# s SEARCH'
|
||||
puts '# d SEARCH'
|
||||
puts '# Add an new item:'
|
||||
puts '# add'
|
||||
puts '# a'
|
||||
puts '# Update an item:'
|
||||
puts '# update ID'
|
||||
puts '# u ID'
|
||||
puts '# Remove an item:'
|
||||
puts '# remove ID'
|
||||
puts '# delete ID'
|
||||
puts '# r ID'
|
||||
puts '# d ID'
|
||||
puts '# Quit the program:'
|
||||
puts '# quit'
|
||||
puts '# exit'
|
||||
puts '# q'
|
||||
when 'quit', 'exit', 'q'
|
||||
break
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
5
mpw
5
mpw
|
@ -97,9 +97,10 @@ elsif not options[:export].nil?
|
|||
# Add a new item
|
||||
elsif not options[:import].nil?
|
||||
cli.import(options[:import], options[:force])
|
||||
else
|
||||
puts "For help add option -h or --help"
|
||||
|
||||
# Interactive mode
|
||||
else
|
||||
cli.interactive
|
||||
end
|
||||
|
||||
exit 0
|
||||
|
|
Loading…
Reference in a new issue