From 627f44ba02ae7c0b1f5bb146207cc82ca31def06 Mon Sep 17 00:00:00 2001 From: nishiki Date: Sun, 25 Aug 2013 10:07:39 +0200 Subject: [PATCH] update comment --- Cli.rb | 15 +++++++++++++++ CliSSH.rb | 4 +++- MPW.rb | 3 ++- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Cli.rb b/Cli.rb index 84dd055..bcbea00 100644 --- a/Cli.rb +++ b/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() diff --git a/CliSSH.rb b/CliSSH.rb index abed7d7..f7e5e1c 100644 --- a/CliSSH.rb +++ b/CliSSH.rb @@ -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 diff --git a/MPW.rb b/MPW.rb index 0bf052a..508b9f5 100644 --- a/MPW.rb +++ b/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)