Sha256: 4f64dfae4aa5dd625f29128d725884f2327e08fceb35588a7478a204cd3629ac

Contents?: true

Size: 1.73 KB

Versions: 2

Compression:

Stored size: 1.73 KB

Contents

#!/usr/bin/env ruby

require 'getopt/long'
require 'devinstall'
require 'devinstall/settings'

begin
  opt =Getopt::Long.getopts(
      ['--version', '-v',],
      ['--package', '-p', Getopt::REQUIRED],
      ['--config', '-c', Getopt::REQUIRED],
      ['--type', '-t', Getopt::REQUIRED],
      ['--env', '-e', Getopt::REQUIRED],
      ['--build', '-b',],
      ['--upload', '-u',],
      ['--install', '-i',],
      ['--test', '-t,'],
      ['--help', '-h',],
  )
rescue
  puts 'Invalid option in command line'
  help!
  exit! 1
end

def help!
  puts 'Usage: pkg-install --config|-c <file> --package|-p <package> --type|-t <package_type> --env|-e <environment> --build|--upload|--install'
end

if opt['version']
  puts "devinstall version #{Devinstall::VERSION}"
  puts "pkg-tool version   #{Devinstall::VERSION}"
  exit(0)
end

if opt['help']
  help!
  exit!(0)
end
unless opt['config']
  puts 'You must specify the config file'
  exit! 1 # Exit 
end
Settings.load! opt['config']

['package', 'env', 'type'].each do |o|
  if Settings.defaults[o.to_sym]
    opt[o]=Settings.defaults[o.to_sym]
  end
end

unless opt['package'] && opt['config'] && opt['type'] && opt['env'] && (opt['build'] || opt['upload'] || opt['install'] || opt['test'])
  puts 'You must speciffy --config file, --package, --type and --env and one of the actions (--build, --install, --upload or --test)'
  exit! 1
end
package=Devinstall::Pkg.new(opt['package'])

if opt['build']
  package.build(opt['type'].to_sym)
elsif opt['install']
  package.build(opt['type'].to_sym)
  package.install(opt['env'].to_sym)
elsif opt['upload']
  package.build(opt['type'].to_sym)
  package.run_tests(opt['env'].to_sym)
  package.upload(opt['env'].to_sym)
elsif opt['test']
  package.run_tests(opt['env'].to_sym)
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
devinstall-0.2.2 bin/pkg-tool
devinstall-0.2.1 bin/pkg-tool