Sha256: ad94436e4e28670cab776ac93e31819352ec084961de106425442ba2b2ef56e4

Contents?: true

Size: 782 Bytes

Versions: 1

Compression:

Stored size: 782 Bytes

Contents

class HappySystem::AxoCommand < DevSystem::SimpleCommand
  
  #

  def call_default
    find!

    env[:axo] = @axo
    HappyBox[:axo].call(env)

    log "done at #{Time.now}"
  end

  def find!
    @name = simple_args[0]

    if @name
      @axo = Liza.const "#{@name}_axo"
      return
    end

    @axo = pick_axo
    @name = @axo.last_namespace.snakecase
  ensure
    log :high, "@name = #{@name}"
    log :high, "@axo = #{@axo}"
  end

  def pick_axo
    axos = Axo.descendants
    options = axos.sort_by(&:last_namespace).map do |axo|
      [
        "#{axo.last_namespace.snakecase.ljust 30} - #{axo} - #{(axo.get :description) || "No description."}",
        axo
      ]
    end.to_h
    TtyInputCommand.pick_one "Pick an Axolotl ASCII Animation to run", options
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lizarb-1.0.5 lib/happy_system/sub/axo/commands/axo_command.rb