Sha256: 982252197976c8d534c672e3f22300f5368a074a0d5d9e00cf7c4b9f2c672aba
Contents?: true
Size: 1.8 KB
Versions: 9
Compression:
Stored size: 1.8 KB
Contents
#!/usr/bin/env ruby require 'pkgforge' require 'mercenary' FILE_NAME = '.pkgforge'.freeze def add_common_opts(cmd) # rubocop:disable Metrics/LineLength cmd.option :directory, '-d DIR', '--directory DIR', 'Change to directory before loading' cmd.option :skipcleanup, '-s', '--skipcleanup', 'Skip cleanup of tmpdirs and tmpfiles' # rubocop:enable Metrics/LineLength end def run_on_file(options) options[:directory] ||= '.' Dir.chdir(options[:directory]) do raise("No #{FILE_NAME} file") unless File.exist? FILE_NAME forge = PkgForge.load_from_file yield forge end end Mercenary.program(:pkgforge) do |p| p.version PkgForge::VERSION p.description 'DSL engine for building Arch packages' p.syntax 'pkgforge <subcommand> [options]' p.command(:build) do |c| c.syntax 'build [options]' c.description 'Build the package' add_common_opts(c) c.action do |_, options| run_on_file(options) do |forge| begin forge.build! forge.test! forge.package! ensure forge.cleanup! unless options[:skipcleanup] end end end end p.command(:release) do |c| c.syntax 'release [options]' c.description 'Release the package' add_common_opts(c) c.action do |_, options| run_on_file(options) do |forge| begin forge.build! forge.test! forge.package! forge.push! ensure forge.cleanup! unless options[:skipcleanup] end end end end p.command(:info) do |c| c.syntax 'info [options]' c.description 'Print package info' add_common_opts(c) c.action do |_, options| run_on_file(options) do |forge| puts "name: #{forge.name}" end end end p.action do puts p exit 1 end end
Version data entries
9 entries across 9 versions & 1 rubygems