require "./service.cr" begin simulation, no_configuration, configuration_file = Baguette::Configuration.option_parser configuration = if no_configuration Baguette::Log.info "do not load a configuration file." Baguette::Configuration::Auth.new else Baguette::Configuration::Auth.get(configuration_file) || Baguette::Configuration::Auth.new end Baguette::Context.verbosity = configuration.verbosity if key_file = configuration.secret_key_file configuration.secret_key = File.read(key_file).chomp end OptionParser.parse do |parser| parser.banner = "usage: authd [options]" parser.on "--storage directory", "Directory in which to store users." do |directory| configuration.storage = directory end parser.on "-k file", "--key-file file", "JWT key file" do |file_name| configuration.secret_key = File.read(file_name).chomp end parser.on "-R", "--allow-registrations", "Allow user registration." do configuration.registrations = true end parser.on "-E", "--require-email", "Require an email." do configuration.require_email = true end parser.on "-t activation-template-name", "--activation-template name", "Email activation template." do |opt| configuration.activation_template = opt end parser.on "-r recovery-template-name", "--recovery-template name", "Email recovery template." do |opt| configuration.recovery_template = opt end parser.on "-m mailer-exe", "--mailer mailer-exe", "Application to send registration emails." do |opt| configuration.mailer_exe = opt end parser.on "-x key", "--read-only-profile-key key", "Marks a user profile key as being read-only." do |key| configuration.read_only_profile_keys.push key end parser.on "-h", "--help", "Show this help" do puts parser exit 0 end end if simulation pp! configuration exit 0 end AuthD::Service.new(configuration).run rescue e : OptionParser::Exception Baguette::Log.error e.message rescue e Baguette::Log.error "exception raised: #{e.message}" e.backtrace.try &.each do |line| STDERR << " - " << line << '\n' end end