def call(
path: nil,
training: false,
ods_code: nil,
workgroup: nil,
type: "point_of_care",
**
)
MavisCLI.load_rails
if training && Rails.env.production?
warn "Cannot create a training team in production."
return
end
if !training && path.blank?
warn "Specify the path to a configuration file."
return
end
config =
if training
unless type.in?(Team.types.keys)
warn "Invalid team type. Must be 'point_of_care' or 'national_reporting'."
return
end
TrainingOnboardingConfiguration.call(ods_code:, workgroup:, type:)
else
YAML.safe_load(File.read(path), permitted_classes: [Date])
end
onboarding = Onboarding.new(config)
if onboarding.valid?
onboarding.save!
else
onboarding.errors.full_messages.each { |message| puts message }
end
end