1
0
Fork 0
mirror of https://github.com/nishiki/manage-password.git synced 2024-10-27 02:33:19 +00:00

add login and password in clipboard

This commit is contained in:
nishiki 2016-07-09 14:06:49 +02:00
parent bbeeb68065
commit e068a2758c
7 changed files with 54 additions and 11 deletions

View file

@ -6,3 +6,4 @@ gem 'gpgme'
gem 'colorize'
gem 'net-ssh'
gem 'net-scp'
gem 'clipboard'

View file

@ -8,6 +8,7 @@ MPW can synchronize your password with SSH or FTP.
This program work with ruby >= 2.0
* install ruby and rubygems on your computer
* install xclip
* gem install mpw
# How to use

19
bin/mpw
View file

@ -48,12 +48,13 @@ I18n.locale = lang.to_sym
# Options
# --------------------------------------------------------- #
options = {}
options[:force] = false
options[:sync] = true
options[:group] = nil
options[:config] = nil
options[:wallet] = nil
options = {}
options[:force] = false
options[:sync] = true
options[:clipboard] = true
options[:group] = nil
options[:config] = nil
options[:wallet] = nil
OptionParser.new do |opts|
opts.banner = "#{I18n.t('option.usage')}: mpw [options]"
@ -71,6 +72,10 @@ OptionParser.new do |opts|
options[:config] = config
end
opts.on('-C', '--no-clipboard', I18n.t('option.clipboard')) do
options[:clipboard] = false
end
opts.on('-d', '--delete', I18n.t('option.remove')) do
options[:delete] = true
end
@ -144,7 +149,7 @@ end.parse!
begin
config = MPW::Config.new(options[:config])
cli = MPW::Cli.new(config, options[:sync])
cli = MPW::Cli.new(config, options[:clipboard], options[:sync])
# Setup a new config
if not options[:setup].nil?

View file

@ -38,6 +38,7 @@ en:
option:
add: "Add an item or key"
config: "Specify the configuration file to use"
clipboard: "Disable the clipboard feature"
export: "Export a wallet in an yaml file"
file: "Specify a file, to use with the options [--import | --export | --add]"
force: "No ask to confirm when you delete an item"
@ -72,6 +73,10 @@ en:
port: "Enter the connection port (optional): "
comment: "Enter a comment (optional): "
valid: "Item has been added!"
clipboard:
clean: "The clipboard has been cleaned."
login: "The login has been copied in clipboard, press any key to continue."
password: "The password has been copied in clipboard for 30s!"
delete_key:
valid: "Key has been deleted!"
delete_item:

View file

@ -38,6 +38,7 @@ fr:
option:
add: "Ajoute un élément ou une clé"
config: "Spécifie le fichier de configuration à utiliser"
clipboard: "Désactive la fonction presse papier"
export: "Exporte un portefeuille dans un fichier yaml"
file: "Spécifie un fichier, à utiliser avec les options [--import | --export | --add]"
force: "Ne demande pas de confirmation pour la suppression d'un élément"
@ -72,6 +73,10 @@ fr:
port: "Entrez le port de connexion (optionnel): "
comment: "Entrez un commentaire (optionnel): "
valid: "L'élément a bien été ajouté!"
clipboard:
clean: "Le presse papier a été nettoyé."
login: "L'identifiant a été copié dans le presse papier, pressez n'importe quelle touche pour continuer."
password: "Le mot de passe a été copié dans le presse papier pour 30s!"
delete_key:
valid: "La clé a bien été supprimée!"
delete_item:

View file

@ -20,6 +20,7 @@ require 'readline'
require 'i18n'
require 'colorize'
require 'highline/import'
require 'clipboard'
#TODO
require "#{APP_ROOT}/../lib/mpw/item.rb"
@ -31,9 +32,10 @@ class Cli
# Constructor
# @args: config -> the config
# sync -> boolean for sync or not
def initialize(config, sync=true)
@config = config
@sync = sync
def initialize(config, clipboard=true, sync=true)
@config = config
@clipboard = clipboard
@sync = sync
end
# Create a new config file
@ -184,11 +186,34 @@ class Cli
print "#{I18n.t('display.login')}: ".cyan
puts item.user
print "#{I18n.t('display.password')}: ".cyan
puts @mpw.get_password(item.id)
if @clipboard
puts '***********'
else
puts @mpw.get_password(item.id)
end
print "#{I18n.t('display.port')}: ".cyan
puts item.port
print "#{I18n.t('display.comment')}: ".cyan
puts item.comment
clipboard(item) if @clipboard
end
# Copy in clipboard the login and password
def clipboard(item)
Clipboard.copy(item.user)
print "\n#{I18n.t('form.clipboard.login')}".green
gets
Clipboard.copy(@mpw.get_password(item.id))
puts I18n.t('form.clipboard.password').yellow
sleep(30)
Clipboard.clear
puts I18n.t('form.clipboard.clean').green
rescue SystemExit, Interrupt
Clipboard.clear
end
# Display the wallet

View file

@ -24,4 +24,5 @@ Gem::Specification.new do |spec|
spec.add_dependency "colorize"
spec.add_dependency "net-ssh"
spec.add_dependency "net-scp"
spec.add_dependency "clipboard"
end