From b8df90b2c29a655c3017947610cbba3d2d175aa2 Mon Sep 17 00:00:00 2001 From: Sam Stephenson Date: Sat, 27 Feb 2010 00:11:35 -0600 Subject: [PATCH] bin/hector-identity --- bin/hector-identity | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100755 bin/hector-identity diff --git a/bin/hector-identity b/bin/hector-identity new file mode 100755 index 0000000..90c7575 --- /dev/null +++ b/bin/hector-identity @@ -0,0 +1,35 @@ +#!/usr/bin/env ruby + +ENV["HECTOR_ROOT"] ||= "." +require File.dirname(__FILE__) + "/../lib/hector/boot" + +def read_password + `stty -echo` + $stderr.print "Enter password: " + $stdin.gets.chomp.tap do + $stderr.print "\n" + end +ensure + `stty echo` +end + +command, username, password = ARGV[0], ARGV[1], ARGV[2] +command = nil unless username + +case command +when "authenticate" + exit Hector::Identity.adapter.authenticate(username, password || read_password) ? 0 : -1 + +when "remember" + Hector::Identity.adapter.remember(username, password || read_password) + +when "forget" + Hector::Identity.adapter.forget(username) + +else + $stderr.puts "usage: hector identity authenticate [password]" + $stderr.puts " hector identity remember [password]" + $stderr.puts " hector identity forget " + exit 1 +end +