Class: MtgCardMaker::CLI

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

Overview

Thor-based command-line interface for MTG Card Maker. Provides commands for generating individual cards and sprite sheets from YAML configuration files.

Examples:

Generate a single card

mtg_card_maker generate_card --name "Lightning Bolt" --type-text "Instant" \
  --rules-text "Lightning Bolt deals 3 damage to any target." --color red

Generate a sprite sheet

mtg_card_maker generate_sprite cards.yml sprite.svg

Add a card to YAML file

mtg_card_maker add_card cards.yml --name "Lightning Bolt" --type-text "Instant" \
  --rules-text "Lightning Bolt deals 3 damage to any target." --color red

Since:

  • 0.1.0

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.card_optionsHash

Define the standard card options for CLI commands

Returns:

  • (Hash)

    the card option definitions for Thor

Since:

  • 0.1.0



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/mtg_card_maker/cli.rb', line 40

def self.card_options
  {
    name: { type: :string, required: true, desc: 'Card name' },
    mana_cost: { type: :string, aliases: ['mana', 'cost'], desc: 'Mana cost (e.g., "2RR", "XG")' },
    type_line: { type: :string, required: true, aliases: ['type'],
                 desc: 'Card type & subtype (e.g., "Creature - Dragon", "Instant")' },
    rules_text: { type: :string, required: true, aliases: ['rules'], desc: 'Card rules text' },
    flavor_text: { type: :string, aliases: ['flavor'], desc: 'Flavor text (optional)' },
    power: { type: :string, desc: 'Power (for creatures)' },
    toughness: { type: :string, desc: 'Toughness (for creatures)' },
    border_color: { type: :string, aliases: ['border'], desc: 'Border color (white, black, gold, silver)' },
    color: { type: :string,
             default: 'colorless',
             desc: 'Card color (white, blue, black, red, green, colorless)' },
    art: { type: :string, aliases: ['artwork', 'image'], desc: 'Image URL or path for card artwork' }
  }
end

.exit_on_failure?Boolean

Returns:

  • (Boolean)

Since:

  • 0.1.0



33
34
35
# File 'lib/mtg_card_maker/cli.rb', line 33

def self.exit_on_failure?
  true
end

Instance Method Details

#add_card(yaml_file) ⇒ Object

Add a new card configuration to YAML file

Since:

  • 0.1.0



107
# File 'lib/mtg_card_maker/cli.rb', line 107

desc 'add_card YAML_FILE [OPTIONS]', 'Add a new card configuration to YAML file'

#generate_cardObject

Generate a single MTG card with specified parameters

Since:

  • 0.1.0



74
# File 'lib/mtg_card_maker/cli.rb', line 74

desc 'generate_card [OPTIONS]', 'Generate a single MTG card with specified parameters'

#generate_sprite(yaml_file, output_file) ⇒ Object

Generate a sprite sheet from YAML configuration

Since:

  • 0.1.0



88
# File 'lib/mtg_card_maker/cli.rb', line 88

desc 'generate_sprite YAML_FILE OUTPUT_FILE [OPTIONS]', 'Generate a sprite sheet from YAML configuration'