Sha256: 77ec3ed169874e2edd6c75f1b53bea6e62399c7b570f1debdfe75d605042b18a

Contents?: true

Size: 974 Bytes

Versions: 29

Compression:

Stored size: 974 Bytes

Contents

#!/usr/bin/env ruby
$: << File.expand_path('lib')

require 'cl'

module Rakeish
  module Db
    class Create < Cl::Cmd
      register 'db:create'

      arg :name

      def run; [registry_key, args, opts] end
    end

    class Drop < Cl::Cmd
      register 'db:drop'

      arg :name

      opt '-f', '--force'

      def run; [registry_key, args, opts] end
    end

    class Migrate < Cl::Cmd
      register 'db:migrate'

      arg :name

      opt '-v', '--version VERSION'

      def run; [registry_key, args, opts] end
    end
  end
end

def output(result)
  result.each do |cmd, args, opts|
    puts "Called #{cmd} with args=#{args} opts=#{opts}"
  end
  puts
end

argv = %w(db:drop production -f db:create db:migrate production -v 1)
output Cl.new($0, runner: :multi).run(argv)

# Output:
#
#   Called db:drop with args=["production"] opts={:force=>true}
#   Called db:create with args=[] opts={}
#   Called db:migrate with args=["production"] opts={:version=>"1"}

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
cl-0.1.8 examples/rakeish
cl-0.1.7 examples/rakeish
cl-0.1.6 examples/rakeish
cl-0.1.5 examples/rakeish
cl-0.1.4 examples/rakeish
cl-0.1.3 examples/rakeish
cl-0.1.2 examples/rakeish
cl-0.1.1 examples/rakeish
cl-0.1.0 examples/rakeish