module Headdesk::CliCommands::Version
Print/compare version
Public Class Methods
included(thor)
click to toggle source
# 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 print_update_message unless Headdesk::Versions.latest_version? exit (Headdesk::Versions.version <=> Gem::Version.new(cmp_version)) > 0 if cmp_version end end end
Public Instance Methods
__version(cmp_version = nil)
click to toggle source
# File lib/headdesk/cli_commands/version.rb, line 23 def __version(cmp_version = nil) STDOUT.puts Headdesk::VERSION print_update_message unless Headdesk::Versions.latest_version? exit (Headdesk::Versions.version <=> Gem::Version.new(cmp_version)) > 0 if cmp_version end