Class: Dmp::CLI
- Inherits:
-
Thor
- Object
- Thor
- Dmp::CLI
- Defined in:
- lib/dmp/cli.rb
Overview
Command line interface for DMP
Instance Method Summary collapse
Instance Method Details
#about ⇒ Object
71 72 73 74 75 76 77 78 79 |
# File 'lib/dmp/cli.rb', line 71 def about # Displays banner, version number and author puts Dmp::BANNER.bold.red puts 'version: '.bold + Dmp::VERSION.green puts 'author: '.bold + '@__franccesco'.green puts 'homepage: '.bold + 'https://github.com/franccesco/dmp'.green puts 'learn more: '.bold + 'https://codingdose.info'.green puts # extra line, somehow I like them. end |
#check_pass ⇒ Object
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/dmp/cli.rb', line 52 def check_pass puts 'Enter your password, press ENTER when you\'re done.' password = ask('Password (hidden):'.yellow, echo: false) # if no password set, just exit if password.empty? puts "Aborted.".red.bold exit end vuln_count = Dmp.check_pwned(password) if vuln_count puts " Your password appears in #{vuln_count} datasets!".red.bold else puts " Your password was not found in a dataset.".green.bold end end |
#gen_pass(pass_length = 7) ⇒ Object
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 |
# File 'lib/dmp/cli.rb', line 19 def gen_pass(pass_length = 7) # Generate colored passphrase passphrase = Dmp.gen_passphrase(pass_length.to_i) # if flag clipboard is 'true' then copy passphrase to clipboard if [:clipboard] Clipboard.copy(passphrase.join(' ')) end # if flag hibp is 'true' then alert the user if [:hibp] vuln_count = Dmp.check_pwned(passphrase) end # colors array will be used to pick a randomized sample # removing black cause it looks ugly in terminals colors = String.colors colors.delete(:black) passphrase.map! do |phrase| rand_color = colors.sample phrase.colorize(rand_color) end puts '- Passphrase: '.bold + passphrase.join(' ') puts '- Copied to clipboard.'.bold.green if [:clipboard] if vuln_count puts "- WARNING: Passphrase appears in #{vuln_count} datasets!".red.bold elsif [:hibp] puts '- Password was not found in a dataset.'.green.bold end end |