module Dep::CLI

Attributes

file[RW]
git[RW]
github[RW]
list[RW]
prerelease[RW]

Public Class Methods

abort() click to toggle source
# File bin/dep, line 204
def self.abort
  abort("error: dep --help for more info")
end
add(name) click to toggle source
# File bin/dep, line 139
def self.add(name)
  if git
    lib = Dep::GitLib.new(name, git)
  elsif github
    lib = Dep::GitHubLib(name, github)
  else
    dependency = Gem::Dependency.new(name)
    fetcher = Gem::SpecFetcher.fetcher

    if fetcher.respond_to?(:spec_for_dependency)
      dependency.prerelease = @prerelease
      res, _ = fetcher.spec_for_dependency(dependency)
    else
      res = fetcher.fetch(dependency, false, true, @prerelease)
    end

    abort("Unable to find #{name}") if res.empty?

    spec = res[-1][0]
    lib  = Dep::Lib.new(spec.name, spec.version)
  end

  @list.add(lib)
  @list.save

  puts "dep: added #{lib}"
end
check() click to toggle source
# File bin/dep, line 174
def self.check
  if @list.missing_libraries.empty?
    puts "dep: all cool"
  else
    puts "dep: the following libraries are missing"

    @list.missing_libraries.each do |lib|
      puts "  %s" % lib
    end

    exit(1)
  end
end
install() click to toggle source
# File bin/dep, line 188
def self.install
  if @list.missing_libraries.empty?
    puts "dep: nothing to install"
    exit
  end

  @list.missing_libraries.each do |lib|
    run lib.install
  end
end
rm(name) click to toggle source
# File bin/dep, line 167
def self.rm(name)
  @list.remove(Dep::Lib.new(name))
  @list.save

  puts "dep: removed #{name}"
end
run(cmd) click to toggle source
# File bin/dep, line 199
def self.run(cmd)
  puts "  #{cmd}"
  `#{cmd}`
end