Class: AgentCode::Commands::GenerateCommand
- Inherits:
-
BaseCommand
- Object
- BaseCommand
- AgentCode::Commands::GenerateCommand
- Defined in:
- lib/agentcode/commands/generate_command.rb
Overview
Interactive scaffold generator — mirrors Laravel php artisan agentcode:generate exactly.
Usage: rails agentcode:generate (or rails agentcode:g)
Instance Method Summary collapse
Methods inherited from BaseCommand
Constructor Details
This class inherits a constructor from AgentCode::Commands::BaseCommand
Instance Method Details
#perform ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/agentcode/commands/generate_command.rb', line 11 def perform print_styled_header type = select("What type of resource would you like to generate?") do || .choice "Model (with migration and factory)", "model" .choice "Policy (extends ResourcePolicy)", "policy" .choice "Scope (for ScopedDB)", "scope" end name = ask("What is the resource name? (PascalCase singular, e.g., Post):") name = name.strip.camelize if name.blank? || name !~ /\A[A-Za-z][A-Za-z0-9]*\z/ say "Invalid name. Must start with a letter and contain only alphanumeric characters.", :red return end case type when "model" generate_model(name) when "policy" generate_policy(name) when "scope" generate_scope(name) end end |