#!/usr/bin/env ruby
# frozen_string_literal: true

require "bundler/setup"
require "hanami/cli"

# Hanami 2.0 does does not officially include database integration. However, much of the required
# work is already done and included in the gem.
#
# This CLI shim activates the database commands so we can manage our app database.

Hanami::CLI.tap do |cli|
  cli.register "db create", Hanami::CLI::Commands::App::DB::Create
  cli.register "db create_migration", Hanami::CLI::Commands::App::DB::CreateMigration
  cli.register "db drop", Hanami::CLI::Commands::App::DB::Drop
  cli.register "db migrate", Hanami::CLI::Commands::App::DB::Migrate
  cli.register "db setup", Hanami::CLI::Commands::App::DB::Setup
  cli.register "db reset", Hanami::CLI::Commands::App::DB::Reset
  cli.register "db rollback", Hanami::CLI::Commands::App::DB::Rollback
  cli.register "db sample_data", Hanami::CLI::Commands::App::DB::SampleData
  cli.register "db seed", Hanami::CLI::Commands::App::DB::Seed
  cli.register "db structure dump", Hanami::CLI::Commands::App::DB::Structure::Dump
  cli.register "db version", Hanami::CLI::Commands::App::DB::Version
end

Hanami::CLI::Bundler.require(:cli)

cli = Dry::CLI.new(Hanami::CLI)
cli.call