Sha256: 4f7fb3a91882721f85012f8b50b0fed48aebb2f5fb2f2f40b114964b450dc1cd

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

# encoding: utf-8
#
require 'kde-build/command'

module BuildTool


  # The default version command. It adds the options "-v" and "--version" to the global options of
  # the associated +CommandParser+. When specified on the command line, it shows the version of the
  # program.
  class VersionCommand < Command

    def initialize
      super( 'version', false )
      self.short_desc = "Show the version of the program"
    end

    def init
      case commandparser.main_command.options
      when CmdParse::OptionParserWrapper
        commandparser.main_command.options.instance do |opt|
          opt.on_tail( "--version", "-v", "Show the version of the program" ) do
            execute( [] )
          end
        end
      end
    end

    def usage
      "Usage: #{commandparser.program_name} version"
    end

    def execute( args )
      version = commandparser.program_version
      version = version.join( '.' ) if version.instance_of?( Array )
      puts commandparser.banner + "\n" if commandparser.banner
      puts version
    end

  end


end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
build-tool-0.0.3 lib/kde-build/command/version.rb
build-tool-0.0.2 lib/kde-build/command/version.rb
build-tool-0.0.1 lib/kde-build/command/version.rb