Module: Headdesk::CliCommands::Version
- Includes:
- Headdesk::CliCommand
- Defined in:
- lib/headdesk/cli_commands/version.rb
Overview
Print/compare version
Class Method Summary collapse
Methods included from Headdesk::CliCommand
Class Method Details
.included(thor) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/headdesk/cli_commands/version.rb', line 14 def self.included(thor) thor.class_eval do map %w[--version] => :__version desc '--version [COMPARE_VERSION]', 'Print, and optionally compare version.' long_desc " `--version` will print the version to STDOUT, and if a newer version is available it will print out an update message to STDERR.\n\n You can optionally specify a version number as a second argument, in which case will compare the current version with that version exit with code 1 if the current version is less than the provided version. It will exit with code 0 if the current version is less than, or equal to the provided version.\n LONGDESC\n def __version(cmp_version = nil)\n STDOUT.puts Headdesk::VERSION\n print_update_message unless Headdesk::Versions.latest_version?\n\n exit (Headdesk::Versions.version <=> Gem::Version.new(cmp_version)) > 0 if cmp_version\n end\n end\nend\n" |