1
0
Fork 0
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:
nishiki 2013-09-08 17:56:10 +02:00
parent c12c370b42
commit 548a1e8fcc
2 changed files with 53 additions and 2 deletions

View file

@ -226,4 +226,54 @@ class Cli
end end
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 end

5
mpw
View file

@ -97,9 +97,10 @@ elsif not options[:export].nil?
# Add a new item # Add a new item
elsif not options[:import].nil? elsif not options[:import].nil?
cli.import(options[:import], options[:force]) cli.import(options[:import], options[:force])
else
puts "For help add option -h or --help"
# Interactive mode
else
cli.interactive
end end
exit 0 exit 0