Class: SpecForge::CLI::New

Inherits:
Command
  • Object
show all
Defined in:
lib/spec_forge/cli/new.rb

Overview

Command for generating new blueprints or factories from templates

Creates workflow blueprints or test data factories with sensible defaults and realistic examples to get you started quickly.

Examples:

Creating a new blueprint

spec_forge new blueprint users

Creating a new factory

spec_forge new factory user

Defined Under Namespace

Classes: Proxy

Instance Attribute Summary

Attributes inherited from Command

#arguments, #options

Instance Method Summary collapse

Methods inherited from Command

aliases, example, #initialize, option, register

Methods included from Actions

included

Constructor Details

This class inherits a constructor from SpecForge::CLI::Command

Instance Method Details

#callvoid

This method returns an undefined value.

Creates a new blueprint or factory file from templates



57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/spec_forge/cli/new.rb', line 57

def call
  type = arguments.first&.downcase
  name = arguments.second

  if type.nil? || name.nil?
    puts "Error: Both type and name are required."
    puts "Usage: spec_forge new <type> <name>"
    puts ""
    puts "Examples:"
    puts "  spec_forge new blueprint users"
    puts "  spec_forge new factory user"
    exit(1)
  end

  # Clean up the name
  name = normalize_name(name)

  case type
  when "blueprint", "blueprints", "spec", "specs"
    create_new_blueprint(name)
  when "factory", "factories"
    create_new_factory(name)
  else
    puts "Error: Unknown type '#{type}'"
    puts "Valid types: blueprint, factory"
    exit(1)
  end
end