Project

d4c

0.0
No commit activity in last 3 years
No release in over 3 years
DSL for add rails console option.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

>= 0

Runtime

>= 5.1.0
 Project Readme

D4C Build Status

Easy add options to Rails console
My blog

Prerequisites

  • Rails >= 5.1.0 Application

Installation

Add this line to your application's Gemfile:

gem 'd4c'

And then execute:

$ bundle

Or install it yourself as:

$ gem install d4c

Usage

Add option in config/application.rb

# frozen_string_literal: true

require_relative 'boot'

require 'rails/all'

Bundler.require(*Rails.groups)

D4C::Console.add_option 'hello' do
  puts "hello"
end

module YourRailsApplication
  class Application < Rails::Application

Note

You need to put D4C::Console.add_option before first Rails::Application. see also: https://guides.rubyonrails.org/configuring.html

Option Description

you can set option description

D4C::Console.add_option 'hello', 'say hello!' do
  puts "hello"
end
$rails c -h
Running via Spring preloader in process 13861
Usage:
  bin/rails console [environment] [options]

Options:
  -e, [--environment=ENVIRONMENT]  # Specifies the environment to run this console under (test/development/production).
  -s, [--sandbox], [--no-sandbox]  # Rollback database modifications on exit.
      [--hello], [--no-hello]      # say hello

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/QWYNG/d4c. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.