Class: Sequelizer::CLI
- Inherits:
-
Thor
- Object
- Thor
- Sequelizer::CLI
- Defined in:
- lib/sequelizer/cli.rb
Overview
CLI
Command line interface for Sequelizer gem using Thor. Provides commands for:
- Updating Gemfile with database adapters
- Initializing .env files with database configuration
- Displaying current configuration
Instance Method Summary collapse
-
#config ⇒ Object
Displays the current database configuration and extensions.
-
#init_env ⇒ Object
Creates a .env file with database configuration parameters.
-
#update_gemfile ⇒ Object
Updates the Gemfile to include the appropriate database adapter gem.
Instance Method Details
#config ⇒ Object
Displays the current database configuration and extensions.
This command shows the resolved configuration options that would be used for database connections, including all merged sources and any Sequel extensions that would be loaded.
93 94 95 96 97 |
# File 'lib/sequelizer/cli.rb', line 93 def config opts = Options.new pp opts.to_hash pp opts.extensions end |
#init_env ⇒ Object
Creates a .env file with database configuration parameters.
This command generates a .env file with SEQUELIZER_* environment variables based on the provided options. It will not overwrite an existing .env file.
75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/sequelizer/cli.rb', line 75 def init_env if File.exist?('.env') puts ".env already exists! I'm too cowardly to overwrite it!" puts "Here's what I would have put in there:" puts make_env() exit(1) end File.open('.env', 'w') do |file| file.puts make_env() end end |
#update_gemfile ⇒ Object
Updates the Gemfile to include the appropriate database adapter gem.
This command analyzes your current database configuration and adds or updates the corresponding database adapter gem in your Gemfile. It supports various adapters including PostgreSQL, MySQL, SQLite, and JDBC-based adapters.
33 34 35 |
# File 'lib/sequelizer/cli.rb', line 33 def update_gemfile GemfileModifier.new().modify end |