mirror of
https://github.com/nishiki/manage-password.git
synced 2024-11-23 05:47:53 +00:00
add text color
This commit is contained in:
parent
6290bfb3bb
commit
ccb0e71edc
4 changed files with 35 additions and 60 deletions
1
Gemfile
1
Gemfile
|
@ -3,6 +3,7 @@ gem 'highline'
|
|||
gem 'i18n', '0.6.9'
|
||||
gem 'locale'
|
||||
gem 'gpgme'
|
||||
gem 'colorize'
|
||||
|
||||
group :ssh do
|
||||
gem 'net-ssh'
|
||||
|
|
|
@ -42,9 +42,9 @@ en:
|
|||
config: "Specify the configuration file to use"
|
||||
setup: "Create a new configuration file"
|
||||
protocol: "Select the items with the specified protocol"
|
||||
export: "Export all items in a CSV file"
|
||||
export: "Export all items in a file"
|
||||
type: "Data's type export file [csv|yaml]"
|
||||
import: "Import item since a CSV file"
|
||||
import: "Import item since a yaml or csv file"
|
||||
force: "Force an action"
|
||||
format: "Change the display items format by an alternative format"
|
||||
generate_password: "Generate a random password (default 8 characters)"
|
||||
|
@ -107,21 +107,8 @@ en:
|
|||
port: "Enter the connection port [%{port}]: "
|
||||
comment: "Enter a comment [%{comment}]: "
|
||||
valid: "Item has been updated!"
|
||||
|
||||
interactive:
|
||||
ask_password: "Password GPG: "
|
||||
bad_password: "Bad password!"
|
||||
goodbye: "Goodbye!"
|
||||
unknown_command: "Unknown command!"
|
||||
option:
|
||||
title: "Help"
|
||||
show: "Search and show the results"
|
||||
group: "Change the group for the search"
|
||||
add: "Add an item"
|
||||
update: "Update an item"
|
||||
remove: "Remove an item"
|
||||
help: "Show this message"
|
||||
quit: "Quit the software"
|
||||
export:
|
||||
valid: "The export in %{file} is succesfull!"
|
||||
|
||||
display:
|
||||
comment: "Comment"
|
||||
|
|
|
@ -42,9 +42,9 @@ fr:
|
|||
config: "Spécifie le fichier de configuration à utiliser"
|
||||
setup: "Création d'un nouveau fichier de configuration"
|
||||
protocol: "Sélectionne les éléments ayant le protocole spécifié"
|
||||
export: "Exporte tous les éléments dans un fichier au format CSV"
|
||||
export: "Exporte tous les éléments dans un fichier"
|
||||
type: "Format des données du fichier d'export [csv|yaml]"
|
||||
import: "Importe des éléments depuis un fichier au format CSV"
|
||||
import: "Importe des éléments depuis un fichier yaml ou csv"
|
||||
force: "Force une action, l'action ne demandera pas de confirmation"
|
||||
format: "Change le format d'affichage des éléments par un alternatif"
|
||||
generate_password: "Génére un mot de passe aléatoire (défaut 8 caractères)"
|
||||
|
@ -107,21 +107,8 @@ fr:
|
|||
port: "Entrez un port de connexion [%{port}]: "
|
||||
comment: "Entrez un commentaire [%{comment}]: "
|
||||
valid: "L'élément a bien été mis à jour!"
|
||||
|
||||
interactive:
|
||||
ask_password: "Mot de passe GPG: "
|
||||
bad_password: "Mauvais mot de passe!"
|
||||
goodbye: "Au revoir!"
|
||||
unknown_command: "Commande inconnue!"
|
||||
option:
|
||||
title: "Aide"
|
||||
show: "Cherche et affiche les résulats"
|
||||
group: "Change de groupe pour la recherche"
|
||||
add: "Ajout un élément"
|
||||
update: "Met à jour un élément"
|
||||
remove: "Supprime un élément"
|
||||
help: "Affiche ce message d'aide"
|
||||
quit: "Quitte le programme"
|
||||
export:
|
||||
valid: "L'export dans %{file} est un succès!"
|
||||
|
||||
display:
|
||||
comment: "Commentaire"
|
||||
|
|
|
@ -8,7 +8,7 @@ require 'highline/import'
|
|||
require 'pathname'
|
||||
require 'readline'
|
||||
require 'i18n'
|
||||
require 'yaml'
|
||||
require 'colorize'
|
||||
|
||||
require "#{APP_ROOT}/lib/MPW"
|
||||
|
||||
|
@ -42,26 +42,26 @@ class Cli
|
|||
|
||||
if not @config.sync_host.nil? and not @config.sync_port.nil?
|
||||
if not @sync.connect(@config.sync_host, @config.sync_user, @config.sync_pwd, @config.sync_path, @config.sync_port)
|
||||
puts "#{I18n.t('display.error')} #1: #{@sync.error_msg}"
|
||||
puts "#{I18n.t('display.error')} #1: #{@sync.error_msg}".red
|
||||
end
|
||||
end
|
||||
|
||||
if @sync.enable
|
||||
if not @mpw.sync(@sync.get(@passwd), @config.last_update)
|
||||
puts "#{I18n.t('display.error')} #2: #{@mpw.error_msg}" if not @mpw.error_msg.nil?
|
||||
puts "#{I18n.t('display.error')} #3: #{@sync.error_msg}" if not @sync.error_msg.nil?
|
||||
puts "#{I18n.t('display.error')} #2: #{@mpw.error_msg}".red if not @mpw.error_msg.nil?
|
||||
puts "#{I18n.t('display.error')} #3: #{@sync.error_msg}".red if not @sync.error_msg.nil?
|
||||
elsif not @sync.update(File.open(@config.file_gpg).read)
|
||||
puts "#{I18n.t('display.error')} #4: #{@sync.error_msg}"
|
||||
puts "#{I18n.t('display.error')} #4: #{@sync.error_msg}".red
|
||||
elsif not @config.set_last_update
|
||||
puts "#{I18n.t('display.error')} #5: #{@config.error_msg}"
|
||||
puts "#{I18n.t('display.error')} #5: #{@config.error_msg}".red
|
||||
elsif not @mpw.encrypt
|
||||
puts "#{I18n.t('display.error')} #6: #{@mpw.error_msg}"
|
||||
puts "#{I18n.t('display.error')} #6: #{@mpw.error_msg}".red
|
||||
else
|
||||
return true
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
puts "#{I18n.t('display.error')} #7: #{e}"
|
||||
puts "#{I18n.t('display.error')} #7: #{e}".red
|
||||
puts @sync.error_msg if not @sync.error_msg.nil?
|
||||
puts @config.error_msg if not @config.error_msg.nil?
|
||||
puts @mpw.error_msg if not @mpw.error_msg.nil?
|
||||
|
@ -101,14 +101,14 @@ class Cli
|
|||
sync_path = sync_path.nil? or sync_path.empty? ? nil : sync_path
|
||||
|
||||
if @config.setup(key, share_keys, language, file_gpg, sync_type, sync_host, sync_port, sync_user, sync_pwd, sync_path)
|
||||
puts I18n.t('form.setup.valid')
|
||||
puts "#{I18n.t('form.setup.valid')}".green
|
||||
else
|
||||
puts "#{I18n.t('display.error')} #8: #{@config.error_msg}"
|
||||
puts "#{I18n.t('display.error')} #8: #{@config.error_msg}".red
|
||||
exit 2
|
||||
end
|
||||
|
||||
if not @config.checkconfig
|
||||
puts "#{I18n.t('display.error')} #9: #{@config.error_msg}"
|
||||
puts "#{I18n.t('display.error')} #9: #{@config.error_msg}".red
|
||||
exit 2
|
||||
end
|
||||
end
|
||||
|
@ -143,9 +143,9 @@ class Cli
|
|||
puts I18n.t('form.setup_gpg_key.wait')
|
||||
|
||||
if @config.setup_gpg_key(password, name, length, expire)
|
||||
puts I18n.t('form.setup_gpg_key.valid')
|
||||
puts "#{I18n.t('form.setup_gpg_key.valid')}".green
|
||||
else
|
||||
puts "#{I18n.t('display.error')} #10: #{@config.error_msg}"
|
||||
puts "#{I18n.t('display.error')} #10: #{@config.error_msg}".red
|
||||
exit 2
|
||||
end
|
||||
end
|
||||
|
@ -158,7 +158,7 @@ class Cli
|
|||
|
||||
@passwd = ask(I18n.t('display.gpg_password')) {|q| q.echo = false}
|
||||
if not @mpw.decrypt(@passwd)
|
||||
puts "#{I18n.t('display.error')} #11: #{@mpw.error_msg}"
|
||||
puts "#{I18n.t('display.error')} #11: #{@mpw.error_msg}".red
|
||||
exit 2
|
||||
end
|
||||
end
|
||||
|
@ -230,12 +230,12 @@ class Cli
|
|||
if @mpw.update(name, group, server, protocol, login, passwd, port, comment)
|
||||
if @mpw.encrypt
|
||||
sync
|
||||
puts I18n.t('form.add.valid')
|
||||
puts "#{I18n.t('form.add.valid')}".green
|
||||
else
|
||||
puts "#{I18n.t('display.error')} #12: #{@mpw.error_msg}"
|
||||
puts "#{I18n.t('display.error')} #12: #{@mpw.error_msg}".red
|
||||
end
|
||||
else
|
||||
puts "#{I18n.t('display.error')} #13: #{@mpw.error_msg}"
|
||||
puts "#{I18n.t('display.error')} #13: #{@mpw.error_msg}".red
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -259,12 +259,12 @@ class Cli
|
|||
if @mpw.update(name, group, server, protocol, login, passwd, port, comment, id)
|
||||
if @mpw.encrypt
|
||||
sync
|
||||
puts I18n.t('form.update.valid')
|
||||
puts "#{I18n.t('form.update.valid')}".green
|
||||
else
|
||||
puts "#{I18n.t('display.error')} #14: #{@mpw.error_msg}"
|
||||
puts "#{I18n.t('display.error')} #14: #{@mpw.error_msg}".red
|
||||
end
|
||||
else
|
||||
puts "#{I18n.t('display.error')} #15: #{@mpw.error_msg}"
|
||||
puts "#{I18n.t('display.error')} #15: #{@mpw.error_msg}".red
|
||||
end
|
||||
else
|
||||
puts I18n.t('display.nothing')
|
||||
|
@ -294,9 +294,9 @@ class Cli
|
|||
if @mpw.remove(id)
|
||||
if @mpw.encrypt
|
||||
sync
|
||||
puts I18n.t('form.delete.valid', id: id)
|
||||
puts "#{I18n.t('form.delete.valid', id: id)}".green
|
||||
else
|
||||
puts "#{I18n.t('display.error')} #16: #{@mpw.error_msg}"
|
||||
puts "#{I18n.t('display.error')} #16: #{@mpw.error_msg}".red
|
||||
end
|
||||
else
|
||||
puts I18n.t('form.delete.not_valid')
|
||||
|
@ -308,9 +308,9 @@ class Cli
|
|||
# @args: file -> the destination file
|
||||
def export(file, type=:yaml)
|
||||
if @mpw.export(file, type)
|
||||
puts "The export in #{file} is succesfull!"
|
||||
puts "#{I18n.t('export.valid', file)}".green
|
||||
else
|
||||
puts "#{I18n.t('display.error')} #17: #{@mpw.error_msg}"
|
||||
puts "#{I18n.t('display.error')} #17: #{@mpw.error_msg}".red
|
||||
end
|
||||
|
||||
end
|
||||
|
@ -339,9 +339,9 @@ class Cli
|
|||
if force
|
||||
if @mpw.import(file, type) and @mpw.encrypt
|
||||
sync
|
||||
puts I18n.t('form.import.valid')
|
||||
puts "#{I18n.t('form.import.valid')}".green
|
||||
else
|
||||
puts "#{I18n.t('display.error')} #18: #{@mpw.error_msg}"
|
||||
puts "#{I18n.t('display.error')} #18: #{@mpw.error_msg}".red
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue