Class: PolypassCLI
- Inherits:
-
Thor
- Object
- Thor
- PolypassCLI
- Defined in:
- lib/polypass/cli.rb
Overview
Thor powered command-line interface
Instance Method Summary collapse
Instance Method Details
#create(type) ⇒ Object
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 |
# File 'lib/polypass/cli.rb', line 28 def create(type) length = [:length].nil? ? 32 : [:length] output = [:output].nil? ? 'stdout' : [:output] unless ['stdout', 'json', 'yaml'].include?(output) raise ArgumentError, output + ' is not a valid output type. ' + 'Available types include: stdout, json, yaml' end case type when 'alphanum' puts 'Generating a new secure random alphanumeric password:' puts Polypass::AlphaNumeric.new(length, output).create when 'alphasym' puts 'Generating a new secure random alphanumeric symbol password:' puts Polypass::AlphaSymbol.new(length, output).create when 'natural' length = [:length].nil? ? 4 : [:length] puts 'Generating a new secure random natural language password:' puts Polypass::NaturalLanguage.new(length, output).create else raise ArgumentError, type + ' is not a valid password type. Avaiable types include: alphanum, alphasym, natural' end end |