Files
fizzy/script/create-new-user.rb
T
2025-10-02 16:33:23 -04:00

27 lines
511 B
Ruby
Executable File

#!/usr/bin/env ruby
require_relative "../config/environment"
if ARGV.length < 3
puts "Usage: #{$0} <tenant> <email> <fullname>"
exit 1
end
tenant = ARGV.shift
email_address = ARGV.shift
name = ARGV.join(" ")
begin
ApplicationRecord.with_tenant(tenant) do
password = SecureRandom.hex(16)
user = User.create!(name:, email_address:, password:)
puts "Created: "
pp user
puts "Password is: #{password.inspect}"
end
rescue Exception => e
puts "Failed with error: #{e.inspect}"
end