aboutsummaryrefslogtreecommitdiff
path: root/bin/keyringer
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2011-01-22 18:24:55 -0200
committerSilvio Rhatto <rhatto@riseup.net>2011-01-22 18:24:55 -0200
commit7382be9d83bc5f95ad8d184b95c379ca5b9d1725 (patch)
tree5ad086f30f59f22e27d427cab1e30ef5282ddbf0 /bin/keyringer
parent42fdb4e702f1235ad6f4ae099f8d265e498a62d4 (diff)
downloadkeyringer-7382be9d83bc5f95ad8d184b95c379ca5b9d1725.tar.gz
keyringer-7382be9d83bc5f95ad8d184b95c379ca5b9d1725.tar.bz2
Code split into backend, keyring and keyringer modules
Diffstat (limited to 'bin/keyringer')
-rwxr-xr-xbin/keyringer30
1 files changed, 9 insertions, 21 deletions
diff --git a/bin/keyringer b/bin/keyringer
index 974fa80..74dfcb1 100755
--- a/bin/keyringer
+++ b/bin/keyringer
@@ -9,31 +9,19 @@ def usage
exit 1
end
-# TODO: misc checks
-def doDecrypt(someArguments)
- filename = ARGV[2]
- file = Keyringer::Fs.new()
- content = file.get_as_string(filename)
-
- crypt = Keyringer::Crypt.new(nil)
- output = crypt.decrypt(content)
- puts output
-end
-
-def doWrapper(someArguments)
- exec("keyringer " + ARGV.join(' '))
-end
-
$:.unshift File.dirname(__FILE__) + '/../lib'
require 'keyringer'
begin
- keyring = ARGV[0]
- action = ARGV[1]
- if action == 'decrypt'
- doDecrypt(ARGV)
- else
- doWrapper(ARGV)
+ action = Keyringer.const_get(ARGV[1].capitalize)
+
+ if action.is_a?(Class)
+ instance = action.new
+ output = instance.execute
+ puts output
end
+rescue NameError
+ wrapper = Keyringer::BashWrapper.new
+ wrapper.execute
rescue SystemExit => e
exit e.status
rescue Exception => e