Class: SecretHub::Commands::Bulk
- Defined in:
- lib/secret_hub/commands/bulk.rb
Instance Method Summary collapse
- #clean_command ⇒ Object
- #init_command ⇒ Object
- #list_command ⇒ Object
- #save_command ⇒ Object
- #show_command ⇒ Object
Methods inherited from Base
Instance Method Details
#clean_command ⇒ Object
82 83 84 85 86 87 88 89 90 91 |
# File 'lib/secret_hub/commands/bulk.rb', line 82 def clean_command dry = args['--dry'] config.each do |repo, secrets| say "b`#{repo}`" clean_repo repo, secrets.keys, dry end say "\nDry run, nothing happened" if dry end |
#init_command ⇒ Object
39 40 41 42 43 44 |
# File 'lib/secret_hub/commands/bulk.rb', line 39 def init_command raise SecretHubError, "File #{config_file} already exists" if File.exist? config_file FileUtils.cp config_template, config_file say "Saved g`#{config_file}`" end |
#list_command ⇒ Object
55 56 57 58 59 60 61 62 |
# File 'lib/secret_hub/commands/bulk.rb', line 55 def list_command config.each_repo do |repo| say "b`#{repo}`:" github.secrets(repo).each do |secret| say "- m`#{secret}`" end end end |
#save_command ⇒ Object
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/secret_hub/commands/bulk.rb', line 64 def save_command dry = args['--dry'] only = args['--only'] skipped = 0 config.each do |repo, secrets| next if only && (repo != only) say "b`#{repo}`" skipped += update_repo repo, secrets, dry clean_repo repo, secrets.keys, dry if args['--clean'] end puts "\n" if skipped.positive? || dry say "Skipped #{skipped} missing secrets" if skipped.positive? say 'Dry run, nothing happened' if dry end |
#show_command ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/secret_hub/commands/bulk.rb', line 46 def show_command config.each do |repo, secrets| say "b`#{repo}`:" secrets.each do |key, value| show_secret key, value, args['--visible'] end end end |