Sha256: 5495afc44b26f2377c900c4bd21e9cf19e2bcfaf50b7e6c5b4900a766b0ee549

Contents?: true

Size: 1.58 KB

Versions: 3

Compression:

Stored size: 1.58 KB

Contents

#!/usr/bin/env ruby
oplop_dir = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib'))
$LOAD_PATH.unshift(oplop_dir) unless $LOAD_PATH.include?(oplop_dir)

require 'oplop'
require 'oplop/cli'
require 'highline/import'
require 'optparse'

# -- exit nicely if control-c
Signal.trap("SIGINT") { exit 2 }

# -- options
options = {}
optparse = OptionParser.new do |opts|
  opts.banner = Oplop::Cli.banner

  options[:verbose] = false
  opts.on( '-v', '--verbose', 'Output the password to STDOUT' ) do
    options[:verbose] = true
  end

  options[:new] = false
  opts.on( '-n', '--new', 'New mode (2 prompt for master)') do
    options[:new] = true
  end

  opts.on( '-h', '--help', 'Display this screen' ) do
    puts opts
    puts "\n"
    puts Oplop::Cli.help
    exit
  end

end.parse!

# -- program
label = ARGV.shift

if label.nil? or label.empty?
  puts "!! You need to pass in a label!"
  exit 2
end


master = ask("Enter your master password: ") { |q| q.echo = "*" }

if options[:new]
  master_confirm = ask("Enter your master password (again): ") { |q| q.echo = "*" }
  if (master != master_confirm)
    puts "!! Your master and confirm don't match!"
    exit 2
  end
end

password = Oplop.password(:label => label, :master => master)

if options[:verbose]
  puts "\n    Password for #{label}:\t#{password}\n\n"
end

if Oplop::Cli.copy_to_clipboard(password)
  print "Your #{label} password has been copied to your clipboard.  \n"
else
  print "!! Could not copy to clipboard, try installing xclip. "
  print "Run with --verbose flag to see password on STDOUT." unless options[:verbose]
  print "\n"
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
oplop-2.1.0 bin/loplop
oplop-2.0.0 bin/loplop
oplop-0.0.8 bin/oplop