Module: Acclaim::Command::Version
- Defined in:
- lib/acclaim/command/version.rb
Overview
Module which adds version query support to a command.
Class Method Summary collapse
-
.create(*args) ⇒ Object
Creates a version subcommand that inherits from the given
basecommand and stores the class in theVersionconstant ofbase.
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.
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 base, opts if opts. true base.const_set(:Version, Class.new(base)).tap do |version_command| version_command.when_called do |, args| puts version_string end end end |