mirror of
https://github.com/nishiki/manage-password.git
synced 2025-03-19 21:04:35 +00:00
update comment
This commit is contained in:
parent
c2665ddcb7
commit
627f44ba02
3 changed files with 20 additions and 2 deletions
15
Cli.rb
15
Cli.rb
|
@ -11,6 +11,7 @@ require "#{APP_ROOT}/MPW.rb"
|
|||
|
||||
class Cli
|
||||
|
||||
# Constructor
|
||||
def initialize()
|
||||
@m = MPW.new()
|
||||
|
||||
|
@ -40,6 +41,7 @@ class Cli
|
|||
end
|
||||
end
|
||||
|
||||
# Request the GPG password and decrypt the file
|
||||
def decrypt()
|
||||
if not @m.checkFilePassword()
|
||||
passwd = ask("Password GPG: ") {|q| q.echo = false}
|
||||
|
@ -49,6 +51,9 @@ class Cli
|
|||
end
|
||||
end
|
||||
|
||||
# Display the query's result
|
||||
# @args: search -> the string to search
|
||||
# protocol -> search from a particular protocol
|
||||
def display(search, protocol=nil)
|
||||
result = @m.search(search, protocol)
|
||||
|
||||
|
@ -68,6 +73,7 @@ class Cli
|
|||
end
|
||||
end
|
||||
|
||||
# Form to add a new item
|
||||
def add()
|
||||
row = Array.new()
|
||||
puts "# Add a new item"
|
||||
|
@ -88,6 +94,8 @@ class Cli
|
|||
end
|
||||
end
|
||||
|
||||
# Update an item
|
||||
# @args: id -> the item's id
|
||||
def update(id)
|
||||
row = @m.searchById(id)
|
||||
|
||||
|
@ -115,6 +123,9 @@ class Cli
|
|||
end
|
||||
end
|
||||
|
||||
# Remove an item
|
||||
# @args: id -> the item's id
|
||||
# force -> no resquest a validation
|
||||
def remove(id, force=false)
|
||||
if not force
|
||||
confirm = ask("Are you sur to remove the item: #{id} ? (y/N) ")
|
||||
|
@ -136,6 +147,8 @@ class Cli
|
|||
end
|
||||
end
|
||||
|
||||
# Export the items in a CSV file
|
||||
# @args: file -> the destination file
|
||||
def export(file)
|
||||
if @m.export(file)
|
||||
puts "The export in #{file} is succesfull!"
|
||||
|
@ -145,6 +158,8 @@ class Cli
|
|||
|
||||
end
|
||||
|
||||
# Import items from a CSV file
|
||||
# @args: file -> the import file
|
||||
def import(file)
|
||||
if @m.import(file)
|
||||
if @m.encrypt()
|
||||
|
|
|
@ -9,6 +9,8 @@ class CliSSH < Cli
|
|||
|
||||
attr_accessor :server, :port, :login
|
||||
|
||||
# Connect to SSH
|
||||
# args: search -> string to search
|
||||
def ssh(search)
|
||||
result = @m.search(search, 'ssh')
|
||||
|
||||
|
@ -24,7 +26,7 @@ class CliSSH < Cli
|
|||
port = 22
|
||||
end
|
||||
|
||||
puts "ssh #{login}@#{server} -p #{port}"
|
||||
puts "Connect to: ssh #{login}@#{server} -p #{port}"
|
||||
if passwd.empty?
|
||||
system("ssh #{login}@#{server} -p #{port}")
|
||||
else
|
||||
|
|
3
MPW.rb
3
MPW.rb
|
@ -95,7 +95,7 @@ class MPW
|
|||
|
||||
# Decrypt a gpg file
|
||||
# @args: password -> the GPG key password
|
||||
# @rtrn: true if data is decrypted
|
||||
# @rtrn: true if data has been decrypted
|
||||
def decrypt(passwd=nil)
|
||||
@data = ""
|
||||
|
||||
|
@ -144,6 +144,7 @@ class MPW
|
|||
end
|
||||
|
||||
# Encrypt a file
|
||||
# @rtrn: true if the file has been encrypted
|
||||
def encrypt()
|
||||
begin
|
||||
crypto = GPGME::Crypto.new(:armor => true)
|
||||
|
|
Loading…
Add table
Reference in a new issue