class RepoMgr::CLI
implements CLI
interface
Public Class Methods
exit_on_failure?()
click to toggle source
# File lib/repo_mgr/cli.rb, line 16 def self.exit_on_failure? true end
publishers()
click to toggle source
# File lib/repo_mgr/cli.rb, line 24 def self.publishers %w[git] end
types()
click to toggle source
# File lib/repo_mgr/cli.rb, line 20 def self.types %w[deb rpm] end
Public Instance Methods
add_pkg()
click to toggle source
# File lib/repo_mgr/cli.rb, line 91 def add_pkg backend, config = load_backend options[:path] backend.add_pkg options[:repo], options[:path] config.add_pkg options[:repo], options[:path] pub_type = config.cfg[:repos][options[:repo]][:publisher] if pub_type publisher = Publishers.load pub_type, config publisher.save options[:repo], options[:path] end puts "-- Added #{File.basename(options[:path])} to "\ "#{options[:repo]} repository" end
check_depends()
click to toggle source
# File lib/repo_mgr/cli.rb, line 30 def check_depends rows = [] %w[aptly dpkg-sig createrepo rpm git].each do |bin_dep| rows << if Tools.which bin_dep [bin_dep, '✔'.green] else [bin_dep, '✘'.red] end end puts Terminal::Table.new headings: %w[Binary Status], rows: rows end
check_sig()
click to toggle source
# File lib/repo_mgr/cli.rb, line 142 def check_sig backend, _config = load_backend options[:path] puts backend.check_sig options[:path] end
export()
click to toggle source
# File lib/repo_mgr/cli.rb, line 182 def export config = Config.new backend = Backends.load config.cfg[:repos][options[:repo]][:type], config backend.export options[:repo] puts "-- Exported #{options[:repo]} repo" end
list_pkgs()
click to toggle source
# File lib/repo_mgr/cli.rb, line 110 def list_pkgs packages = Config.new.cfg[:packages][options[:repo]] if packages.nil? Tools.error "#{options[:repo]} repo does not have any packages" end rows = packages.sort.each_with_index.map { |e, i| [i + 1, e] } puts Terminal::Table.new headings: ['#', "Packages in #{options[:repo]}"], rows: rows end
list_repos()
click to toggle source
# File lib/repo_mgr/cli.rb, line 70 def list_repos rows = [] config = Config.new config.cfg[:repos].each do |name, repo| rows << [name, repo[:type], repo[:path], repo[:keyid], repo[:publisher]] end return puts '-- No repos have been created' if rows.count.zero? puts Terminal::Table.new( headings: %w[Name Type Path KeyID Publisher], rows: rows ) end
rebuild_pkg_list()
click to toggle source
# File lib/repo_mgr/cli.rb, line 150 def rebuild_pkg_list config = Config.new backend = Backends.load config.cfg[:repos][options[:repo]][:type], config pkgs = backend.rebuild_pkg_list options[:repo] pkgs.each do |pkg| config.add_pkg options[:repo], pkg end puts "-- Rebuilt #{options[:repo]} repo pkg list" end
remove_pkg()
click to toggle source
# File lib/repo_mgr/cli.rb, line 129 def remove_pkg backend, config = load_backend options[:path] backend.remove_pkg options[:repo], options[:path] config.remove_pkg options[:repo], options[:path] puts "-- Removed #{File.basename(options[:path])} from "\ "#{options[:repo]} repository" end
sync()
click to toggle source
# File lib/repo_mgr/cli.rb, line 165 def sync config = Config.new pub_type = config.cfg[:repos][options[:repo]][:publisher] unless pub_type Tools.error "#{options[:repo]} repo does not have a publisher" end publisher = Publishers.load pub_type, config publisher.sync options[:repo] puts "-- Synchronised #{options[:repo]} using #{pub_type} publisher" end
upsert_repo()
click to toggle source
# File lib/repo_mgr/cli.rb, line 56 def upsert_repo FileUtils.mkdir_p options[:path] config = Config.new config.upsert_repo options backend = Backends.load options[:type], config backend.add_repo options[:name] puts "-- Upserted #{options[:name]} repository" end
Private Instance Methods
load_backend(path)
click to toggle source
# File lib/repo_mgr/cli.rb, line 193 def load_backend(path) type = File.extname(path).strip.downcase[1..-1] unless CLI.types.include? type Tools.error "unsupported package type #{type}" end config = Config.new [Backends.load(type, config), config] end