Sha256: b43c6f56610b750724f89bb5208637b5518ad9420c9453efbadad68a3cc1595a

Contents?: true

Size: 768 Bytes

Versions: 3

Compression:

Stored size: 768 Bytes

Contents

#!/usr/bin/env ruby
require 'ostruct'
require 'optparse'

require 'hrw'

ARGV << '--help' if ARGV.empty?

options = OpenStruct.new
OptionParser.new do |opt|
  opt.banner = "usage: #{__FILE__} [OPTIONS]"

  opt.on('-u', '--url [URL]', 'remote api url') do |url|
    options.url = url
  end
end.parse!

if options.url.nil?
  if ENV.key?(Hrw::ENV)
    options.url = ENV[Hrw::ENV]
  else
    puts '[-] no url'
    exit(1)
  end
end

scanner = Hrw::Detector.detect
if scanner.nil?
  puts '[-] can not detect package manager, skip'
  exit(0)
end

specs = scanner.scan

api = Hrw::API.new(options.url)
hash = api.submit(specs, scanner.package_manager)
result = api.retrieve(hash)

formatter = Hrw::Formatter.new
if formatter.pretty_print(result)
  exit(1)
else
  exit(0)
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hrw-0.3.6 exe/hrw
hrw-0.3.5 exe/hrw
hrw-0.3.4 exe/hrw