summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormh <mh@immerda.ch>2012-12-30 14:47:00 +0100
committermh <mh@immerda.ch>2012-12-30 14:47:00 +0100
commitf76b1c637bfc5279a7f96e122586d169a65a3a1a (patch)
treefa97ceb7c9d1215d13cce8e1a80aea4498ca42f8
parent506ee7c16e3d7689a78db6b3ed31f6e93b96cd69 (diff)
rearrange format checking
-rwxr-xr-xbin/trocla10
1 files changed, 3 insertions, 7 deletions
diff --git a/bin/trocla b/bin/trocla
index 5b8ed55..39b9e76 100755
--- a/bin/trocla
+++ b/bin/trocla
@@ -39,7 +39,6 @@ OptionParser.new do |opts|
end.parse!
def create(options)
- check_format(options[:trocla_format])
Trocla.new(options.delete(:config_file)).password(
options.delete(:trocla_key),
options.delete(:trocla_format),
@@ -48,14 +47,12 @@ def create(options)
end
def get(options)
- check_format(options[:trocla_format])
Trocla.new(options.delete(:config_file)).get_password(
options.delete(:trocla_key),
options.delete(:trocla_format)
)
end
def set(options)
- check_format(options[:trocla_format])
if options.delete(:ask_password)
require 'highline/import'
password = ask("Enter your password: ") { |q| q.echo = "x" }
@@ -76,7 +73,6 @@ def set(options)
end
def reset(options)
- check_format(options[:trocla_format])
Trocla.new(options.delete(:config_file)).reset_password(
options.delete(:trocla_key),
options.delete(:trocla_format),
@@ -95,11 +91,10 @@ def check_format(format_name)
if format_name.nil?
STDERR.puts "Missing format, exiting..."
exit 1
- elsif not Trocla::Formats.available?(format_name)
- STDERR.puts ":: Error: The format #{format_name} is not available"
+ elsif !Trocla::Formats.available?(format_name)
+ STDERR.puts "Error: The format #{format_name} is not available"
exit 1
end
- false
end
actions=['create','get','set','reset','delete']
@@ -108,6 +103,7 @@ if !(ARGV.length < 2) && (action=ARGV.shift) && actions.include?(action)
options[:trocla_key] = ARGV.shift
options[:trocla_format] = ARGV.shift
options[:other_options] = ARGV
+ check_format(options[:trocla_format]) unless action == 'delete'
begin
if result = send(action,options)
puts result.is_a?(String) ? result : result.inspect