Sha256: b213ea6987607f22ba5b3a9c335121e6d68f7a34a4bc8a15bbf048151eb3fee1

Contents?: true

Size: 1.3 KB

Versions: 14

Compression:

Stored size: 1.3 KB

Contents

#!/usr/bin/env ruby

$LOAD_PATH.unshift(File.expand_path('../../lib',__FILE__))
require 'command_kit/command'

class Command < CommandKit::Command

  usage '[OPTIONS] [-o OUTPUT] FILE'

  option :count, short: '-c',
                 value: {
                   type: Integer,
                   default: 1
                 },
                 desc: "Number of times"

  option :output, value: {
                    type: String,
                    usage: 'FILE'
                  },
                  short: '-o',
                  desc: "Optional output file"

  option :verbose, short: '-v', desc: "Increase verbose level" do
    @verbose += 1
  end

  argument :file, required: true,
                  usage: 'FILE',
                  desc: "Input file"

  examples [
    '-o path/to/output.txt path/to/input.txt',
    '-v -c 2 -o path/to/output.txt path/to/input.txt'
  ]

  description "Example command"

  def initialize
    super

    @verbose = 0
  end

  def run(file)
    unless options.empty?
      puts "Options:"
      options.each do |name,value|
        puts "  #{name.inspect} => #{value.inspect}"
      end
      puts
    end

    puts "Arguments:"
    puts "  file = #{file.inspect}"
    puts

    puts "Custom Variables:"
    puts "  version = #{@verbose.inspect}"
  end
end

if __FILE__ == $0
  Command.start
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
command_kit-0.6.0 examples/command.rb
command_kit-0.5.6 examples/command.rb
command_kit-0.5.5 examples/command.rb
command_kit-0.5.4 examples/command.rb
command_kit-0.5.3 examples/command.rb
command_kit-0.5.2 examples/command.rb
command_kit-0.5.1 examples/command.rb
command_kit-0.5.0 examples/command.rb
command_kit-0.4.1 examples/command.rb
command_kit-0.4.0 examples/command.rb
command_kit-0.3.0 examples/command.rb
command_kit-0.2.2 examples/command.rb
command_kit-0.2.1 examples/command.rb
command_kit-0.2.0 examples/command.rb