Class: Dply::Cli::InstallPkgs

Inherits:
Object
  • Object
show all
Includes:
Helper
Defined in:
lib/dply/cli/install_pkgs.rb

Instance Method Summary collapse

Methods included from Helper

#cmd, #error, #git, #logger, #sh, #symlink

Constructor Details

#initialize(argv) ⇒ InstallPkgs

Returns a new instance of InstallPkgs.



11
12
13
14
# File 'lib/dply/cli/install_pkgs.rb', line 11

def initialize(argv)
  @argv = argv
  @options = {}
end

Instance Method Details

#optsObject



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/dply/cli/install_pkgs.rb', line 25

def opts
  OptionParser.new do |opts|

    opts.banner = "Usage: drake install-pkgs [options] [target]"

    opts.on("-b" , "Build mode") do |b|
      @options[:build_mode] = true
    end

    opts.on("-h", "--help", "Help") do
      puts opts
      exit
    end
  end
end

#runObject



16
17
18
19
20
21
22
23
# File 'lib/dply/cli/install_pkgs.rb', line 16

def run
  opts.parse!(@argv)
  path = Constants::PKGS_YML
  error "#{path} cannot be a symlink" if File.symlink? path
  pkgs = Pkgs.new(path)
  pkgs.install(build_mode: @options[:build_mode])
  puts "installed"
end