Class: Suspenders::CLI

Inherits:
Object
  • Object
show all
Defined in:
lib/suspenders/cli.rb

Overview

Command-line interface for generating Rails applications with Suspenders. This class handles the creation of new Rails apps using a custom template and predefined configuration options.

Constant Summary collapse

BASE_OPTIONS =

Base options passed to the Rails generator for all new applications. These options configure PostgreSQL as the database, skip test setup, and skip Solid-related features.

[
  "-d=postgresql",
  "--skip-test",
  "--skip-solid"
]

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(app_name) ⇒ CLI

Initializes a new CLI instance.

Parameters:

  • app_name (String)

    the name of the Rails application to create



20
21
22
# File 'lib/suspenders/cli.rb', line 20

def initialize(app_name)
  @app_name = app_name
end

Class Method Details

.run(app_name) ⇒ Boolean

Creates and runs a new CLI instance for the given application name.

Parameters:

  • app_name (String)

    the name of the Rails application to create

Returns:

  • (Boolean)

    true if the Rails app was created successfully

Raises:

  • (Error)

    if Rails is not installed or app creation fails



29
30
31
# File 'lib/suspenders/cli.rb', line 29

def self.run(app_name)
  new(app_name).run
end

Instance Method Details

#runBoolean

Executes the CLI workflow to generate a new Rails application. Verifies Rails installation and generates the app with Suspenders template.

Returns:

  • (Boolean)

    true if the Rails app was created successfully

Raises:

  • (Error)

    if Rails is not installed or app creation fails



38
39
40
41
# File 'lib/suspenders/cli.rb', line 38

def run
  verify_rails_exists!
  generate_new_rails_app
end