Sha256: 070141224d46c5eb1af2c77a2553c888b7e669df2b414d5375ddd90ce91959e2

Contents?: true

Size: 471 Bytes

Versions: 5

Compression:

Stored size: 471 Bytes

Contents

require "delegate"

class Bard::CLI::Command < SimpleDelegator
  def self.desc command, description
    @command = command
    @method = command.split(" ").first.to_sym
    @description = description
  end

  def self.setup cli
    cli.desc @command, @description

    method = @method # put in local variable so next block can capture it
    cli.define_method method do |*args|
      command = Bard::CLI::New.new(self)
      command.send method, *args
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
bard-1.3.4 lib/bard/cli/command.rb
bard-1.3.3 lib/bard/cli/command.rb
bard-1.3.2 lib/bard/cli/command.rb
bard-1.3.1 lib/bard/cli/command.rb
bard-1.3.0 lib/bard/cli/command.rb