Sha256: 646ab4cd4decc8db0e343af509ec1ce73bcd150f645a0804687ffe99ad18f2f1

Contents?: true

Size: 1.35 KB

Versions: 3

Compression:

Stored size: 1.35 KB

Contents

#!/usr/bin/env ruby

require 'targit'
require 'mercenary'

def upload(file, repo, tag, options)
  asset = Targit.new(file, repo, tag, options)
  asset.upload!
  puts "Successfully created asset! #{asset.url}"
end

Mercenary.program(:targit) do |p|
  p.version Targit::VERSION
  p.description 'Tool for adding GitHub release assets'
  p.syntax 'targit [options] USER/REPO TAG /path/to/file'

  # rubocop:disable Style/LineLength
  p.option :force, '-f', '--force', 'Replace the asset if it already exists'
  p.option :create, '-c', '--create [NAME]', 'Create release if it does not exist'
  p.option :prerelease, '-p', '--prerelease', 'With -c, create as a dev release'
  p.option :authfile, '-a FILE', '--authfile FILE', 'Set the auth file for GitHub credentials'
  p.option :name, '-n NAME', '--name NAME', 'Set the name for the release asset'
  # rubocop:enable Style/LineLength

  p.action do |_, options|
    repo, tag = ARGV.shift 2
    if !repo || !tag
      puts p
    elsif !ARGV.empty?
      ARGV.each { |file| fail("#{file} not found") unless File.exist? file }
      ARGV.each do |file|
        puts "Adding #{file} on #{tag} of #{repo}"
        upload file, repo, tag, options
      end
    elsif !STDIN.tty?
      fail('Name required if file is passed via STDIN') unless options[:name]
      upload STDIN, repo, tag, options
    else
      puts p
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
targit-0.1.5 bin/targit
targit-0.1.4 bin/targit
targit-0.1.3 bin/targit