Sha256: 288c75d0df43f04626f3769cb8cfa3083d1af28759dd215a438118629ca55394

Contents?: true

Size: 1.31 KB

Versions: 2

Compression:

Stored size: 1.31 KB

Contents

require 'debsacker'
require 'debsacker/options/version_factory'

module Debsacker
  module Options
    class Config

      def self.build
        dependencies = {}
        options = parse
        dependencies[:version] = Debsacker::Options::VersionFactory.build(options)
        dependencies[:control] =  Debsacker::Package::Control.new('debian/control')
        
        dependencies
      end

    private

      def self.parse
        options = {}
        OptionParser.new do |opts|
          opts.banner = 'Usage: debsacker [options]'

          opts.on('-pPACKAGE', '--package=PACKAGE', String, 'Define package version by tag, commit, datetime or explicit version name') do |v|
            options[:version] = v
          end

          opts.on('-d', '--[no-]distro', 'Add distro name to version name (default true)') do |add|
            options[:distro] = add
          end

          opts.on('-b', '--[no-]branch', 'Add branch name to version name (default false)') do |add|
            options[:branch] = add
          end

          opts.on_tail('-h', '--help', 'Show this message') do
            puts opts
            exit
          end

          opts.on_tail('-v', '--version', 'Show version') do
            puts Debsacker::VERSION
            exit
          end
        end.parse!

        options
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
debsacker-0.1.5 lib/debsacker/options.rb
debsacker-0.1.3 lib/debsacker/options.rb