Class: Pass::CLI
- Inherits:
-
Object
- Object
- Pass::CLI
- Defined in:
- lib/pass/cli.rb
Defined Under Namespace
Classes: Error
Instance Method Summary collapse
Instance Method Details
#exec(argv) ⇒ Object
9 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 51 52 53 54 55 56 |
# File 'lib/pass/cli.rb', line 9 def exec(argv) = {} [:length] = Pass::DEFAULT_PASSWORD_LENGTH opts = OptionParser.new opts.on('-c [NUMBER]', '(deprecated) specify password length') do |value| [:length] = option_to_i(value) end opts.on('-l', '--length [NUMBER]', 'specify password length') do |value| [:length] = option_to_i(value) end opts.on('-s', '--symbols', 'include symbols') do |value| [:symbols] = value end opts.on('-e', '--exclude [CHARACTERS]', 'exclude characters') do |value| [:exclude] = value end opts.on_tail('-v', '--version', 'show version') do puts "pass #{Pass::VERSION}" exit 0 end opts. = begin res_argv = opts.parse!(argv) num_passwords = if res_argv[0] option_to_i(res_argv[0]) else Pass::DEFAULT_NUM_PASSWORDS end pass = Pass.new(**) num_passwords.times do puts pass.generate end rescue Pass::Error, Pass::CLI::Error, OptionParser::ParseError => e abort "Error: #{e.}" end exit 0 end |