Permalink
Browse files

Allow a CLI user to pass a password switch.

  • Loading branch information...
1 parent 7e26340 commit 10314599a333559fcc88a567e37825e373b48ce6 @Manfred Manfred committed Oct 16, 2012
Showing with 14 additions and 2 deletions.
  1. +9 −2 lib/oja/cli.rb
  2. +5 −0 spec/cli_spec.rb
View
@@ -8,21 +8,28 @@ def initialize(argv)
end
def usage
- puts "Usage: #{File.basename($0)} <receipt-file>"
+ puts "Usage: #{File.basename($0)} <receipt-file> [options]"
+ puts ""
+ puts "Options"
+ puts " -p, --password <password>"
end
def receipt_filename
@argv[0]
end
+ def password
+ @options['p'] || @options['password']
+ end
+
def print_receipt_details(receipt_data)
receipt_data.each do |key, value|
puts "#{key}: #{value}"
end
end
def check_receipt
- if response = Oja.verify_filename(receipt_filename)
+ if response = Oja.verify_filename(:filename => receipt_filename, :password => password)
if response.active?
puts "[!] Receipt appears to be valid and active"
puts
View
@@ -17,6 +17,11 @@
output.should.include 'product_id'
end
+ it "allows you to pass a password" do
+ cli = Oja::CLI.new([receipt_filename('receipt'), '--password', 'secret'])
+ cli.password.should == 'secret'
+ end
+
it "shows a message when the receipt is invalid" do
Oja::Mock.responses << [200, { status: Oja::Response.status_code(:inactive) }]
output = oja(receipt_filename('receipt'))

0 comments on commit 1031459

Please sign in to comment.