Module: CommandKit::Options::Version

Defined in:
lib/command_kit/options/version.rb

Overview

Defines a version option.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(command) ⇒ Object

Includes CommandKit::Options, extends ClassMethods, and defines a -V, --version option.



13
14
15
16
17
18
19
20
21
22
# File 'lib/command_kit/options/version.rb', line 13

def self.included(command)
  command.include Options
  command.extend ClassMethods

  command.option :version, short: '-V',
                           desc: 'Prints the version and exits' do
    print_version
    exit(0)
  end
end

Instance Method Details

Prints the version.



63
64
65
# File 'lib/command_kit/options/version.rb', line 63

def print_version
  puts "#{command_name} #{version}"
end

#versionObject



54
55
56
# File 'lib/command_kit/options/version.rb', line 54

def version
  self.class.version
end