Class: RailsLens::CLI

Inherits:
Thor
  • Object
show all
Includes:
CLIErrorHandler
Defined in:
lib/rails_lens/cli.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from CLIErrorHandler

#with_error_handling

Class Method Details

.exit_on_failure?Boolean

Thor configuration: exit with proper status codes on failure (modern behavior)

Returns:

  • (Boolean)


12
13
14
# File 'lib/rails_lens/cli.rb', line 12

def self.exit_on_failure?
  true
end

Instance Method Details

#annotateObject



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/rails_lens/cli.rb', line 29

def annotate
  with_error_handling do
    setup_environment

    results = {}
    commands = Commands.new(self)

    # Annotate models (default behavior or when --all is specified)
    results[:models] = commands.annotate_models(options) if target_models?

    # Annotate routes
    results[:routes] = commands.annotate_routes(options) if target_routes?

    # Annotate mailers
    results[:mailers] = commands.annotate_mailers(options) if target_mailers?

    results
  end
end

#checkObject



107
108
109
110
111
112
113
114
# File 'lib/rails_lens/cli.rb', line 107

def check
  with_error_handling do
    setup_environment

    commands = Commands.new(self)
    commands.check(options)
  end
end

#config(subcommand = 'show') ⇒ Object



119
120
121
122
123
124
125
126
# File 'lib/rails_lens/cli.rb', line 119

def config(subcommand = 'show')
  with_error_handling do
    setup_environment

    commands = Commands.new(self)
    commands.config(subcommand, options)
  end
end

#erdObject



77
78
79
80
81
82
83
84
85
86
87
88
# File 'lib/rails_lens/cli.rb', line 77

def erd
  with_error_handling do
    setup_environment

    # Transform CLI options to visualizer options
    visualizer_options = options.dup
    visualizer_options[:output_dir] = options[:output] if options[:output]

    commands = Commands.new(self)
    commands.generate_erd(visualizer_options)
  end
end

#installObject



130
131
132
133
134
135
# File 'lib/rails_lens/cli.rb', line 130

def install
  with_error_handling do
    commands = Commands.new(self)
    commands.install(options)
  end
end

#lintObject



97
98
99
100
101
102
103
104
# File 'lib/rails_lens/cli.rb', line 97

def lint
  with_error_handling do
    setup_environment

    commands = Commands.new(self)
    commands.lint(options)
  end
end

#removeObject



53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
# File 'lib/rails_lens/cli.rb', line 53

def remove
  with_error_handling do
    setup_environment

    results = {}
    commands = Commands.new(self)

    # Remove model annotations (default behavior or when --all is specified)
    results[:models] = commands.remove_models(options) if target_models?

    # Remove route annotations
    results[:routes] = commands.remove_routes(options) if target_routes?

    # Remove mailer annotations
    results[:mailers] = commands.remove_mailers(options) if target_mailers?

    results
  end
end

#versionObject



91
92
93
# File 'lib/rails_lens/cli.rb', line 91

def version
  say "Rails Lens #{RailsLens::VERSION}"
end