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