Module: Oplop::Cli

Defined in:
lib/oplop/cli.rb

Class Method Summary collapse

Class Method Details



6
7
8
# File 'lib/oplop/cli.rb', line 6

def self.banner
  "Usage: oplop [OPTIONS] [label]"
end

.clipboard(copy_program, string) ⇒ Object



58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/oplop/cli.rb', line 58

def self.clipboard(copy_program, string)
  Open3.popen3(copy_program) do |stdin, stdout, stderr, wait_thr|
    stdin.print string
    stdin.close
    # ruby 1.9 has wait_thr, 1.8 doesn't
    if wait_thr.nil?
      !! stderr.read.strip
    else
      wait_thr.status
    end
  end
end

.copy_to_clipboard(string) ⇒ Object



52
53
54
55
56
# File 'lib/oplop/cli.rb', line 52

def self.copy_to_clipboard(string)
  copy_program = `which pbcopy`.strip
  copy_program = `which xclip`.strip if copy_program.empty?
  clipboard(copy_program, string) unless copy_program.empty?
end

.helpObject



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/oplop/cli.rb', line 10

def self.help
  help = <<-HELP
This is a simple cli program to generate oplop passwords.

You will be prompted for your master password.

The default behavior is to copy the password to your clipboard, and not display
it.  This works if you are on a Mac (and/or have pbcopy installed), or if you
have xclip (installed for Linux).

If you do not have pbcopy or xclip, you will have to run the program in verbose
mode (--verbose).

Here are some examples:

Copy my github password to clipboard:
  oplop github

Print my gmail password to STDOUT.
  oplop --verbose gmail

Copy a new password for amazon (prompts for master twice):
  oplop --new amazon

NEW: loplop

There is a new cli program called `loplop`, or long oplop.  It will default to
passwords of 16 characters. It also has a new UX feature to specify the length:

  loplop <n>*<label>

Where <n> is how long the password will be. The max is 22 characters. If you
start a label with *, it is a short-cut to the legacy length 8 (in other words
`8*label` and `*label` will generate the same password).

See: https://github.com/thedod/loplop


Feedback, patches and bugs: https://github.com/bkaney/oplop
HELP
end