Sha256: e24790d75c44a69da3c2cbc7939a7b43c8987a22faa69bc6777cf630407d1513
Contents?: true
Size: 1.54 KB
Versions: 1
Compression:
Stored size: 1.54 KB
Contents
#!/usr/bin/env ruby require_relative "../lib/2pass" def help_message puts <<~HELP Usage: 2pass add <vault_name> <id> <value> - Add new secret 2pass get <vault_name> <id> - Get content by ID from the specified vault 2pass list <vault_name> - List the content of the specified vault 2pass link <vault_name> <target_path> - Create a symlink for an existing vault. Useful when the vault is stored in a synced place (iCloud, Dropbox, etc.) 2pass -h - Display this help message HELP end options = {} OptionParser.new do |opts| opts.banner = "Usage: 2pass [options]" opts.on("-h", "--help", "Display this help message") do options[:help] = true end end.parse! if options[:help] help_message exit end if ARGV.length < 2 help_message exit(1) end command, vault_name, *args = ARGV begin case command when "get" if args.length < 1 help_message exit(1) end id = args[0] puts TwoPass.get_secret(vault_name, id) when "add" if args.length != 2 help_message exit(1) end TwoPass.add_secret(vault_name, args[0], args[1]) when "list" puts TwoPass.list_content(vault_name) when "link" if args.length < 1 help_message exit(1) end target_path = args[0] TwoPass.create_symlink(vault_name, target_path) when "help" help_message else help_message end rescue => e STDERR.puts e.message if ENV["DEBUG"] STDERR.puts STDERR.puts e.backtrace end exit 1 end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
2pass-1.0.0 | bin/2pass |