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 <<~LONGDESC `--version` will print the version to STDOUT, and if a newer version is available it will print out an update message to STDERR. 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. LONGDESC def __version(cmp_version = nil) STDOUT.puts Headdesk::VERSION unless Headdesk::Versions.latest_version? exit (Headdesk::Versions.version <=> Gem::Version.new(cmp_version)) > 0 if cmp_version end end end |