#!/usr/pkg/bin/ruby34
#
# create a new person 
# Usage:  createperson <M|W> <Name> 

require 'university'
require 'vapor'

# create a Person with information given on the command line
if ARGV.size < 2 then
  STDERR << "Usage: $0 <M|F> <Name>\n"
  exit 1
end

gender = 
  case ARGV[0]
  when "M" then "Male"
  when "F" then "Female"
  else
    STDERR << "Usage: $0 <M|F> <Name>\n"
    exit 1
  end
ARGV.shift

name = ARGV.join(' ')
person = Person.new( name, gender )

# connect to Repository
pmgr = Vapor::PersistenceManager.new( Properties )

# make the new University persistent
pmgr.transaction.begin
  person.make_persistent
pmgr.teansaction.commit
