Module: Acclaim::Command::Version

Defined in:
lib/acclaim/command/version.rb

Overview

Module which adds version query support to a command.

Since:

  • 0.0.1

Class Method Summary collapse

Class Method Details

.create(*args) ⇒ Object

Creates a version subcommand that inherits from the given base command and stores the class in the Version constant of base. When called, the command displays the version_string of the program and then exits.

The last argument can be a configuration hash, which accepts the following options:

:options

If true, will add a version option to the base command.

:switches

The switches used when creating the version option.

Since:

  • 0.0.1



22
23
24
25
26
27
28
29
30
# File 'lib/acclaim/command/version.rb', line 22

def create(*args)
  opts, base, version_string = args.extract_ribbon!, args.shift, args.shift
  add_options_to! base, opts if opts.options? true
  base.const_set(:Version, Class.new(base)).tap do |version_command|
    version_command.when_called do |options, args|
      puts version_string
    end
  end
end