Sha256: 48714f47bba5677b7a80ad325984f70000fed6a411c111a2acf3459b2154d4b8

Contents?: true

Size: 876 Bytes

Versions: 2

Compression:

Stored size: 876 Bytes

Contents

#!/usr/bin/env ruby

lib_path = File.expand_path("#{File.dirname(__FILE__)}/../lib")
$LOAD_PATH << lib_path if File.exist?(lib_path) && !$LOAD_PATH.include?(lib_path)

require 'sym'
require 'sym/app'
require 'sym/app/keychain'
require 'colored2'

def usage
  puts "Usage: #{'keychain'.bold.blue}#{' name [ add <contents> | find | delete ]'.bold.green}"
  exit 0
end

usage if ARGV.empty?

key_name, action, data = ARGV

unless %i(add find delete).include?(action.to_sym)
  puts "Error: operation #{action.bold.red} is not recognized"
  usage
end

if action.eql?('add') && data.nil?
  puts "Error: please provide data to store with the #{'add'.bold.green} operation."
  usage
end

begin
puts data ? \
  Sym::App::KeyChain.new(key_name).send(action.to_sym, data) :
  Sym::App::KeyChain.new(key_name).send(action.to_sym)
rescue StandardError => e
  warn "#{e.message.red}"
end


Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sym-3.0.2 exe/keychain
sym-3.0.1 exe/keychain