Class: TapDance::CLI

Inherits:
Thor
  • Object
show all
Defined in:
lib/tap_dance/cli.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(*args, &block) ⇒ CLI

Returns a new instance of CLI.



28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/tap_dance/cli.rb', line 28

def initialize(*args, &block)
  super(*args, &block)

  # Activate shell output
  TapDance.ui = UI::Shell.new(options)
  TapDance.ui.level = "debug" if options["verbose"]

  # Make sure homebrew is installed
  unless command?(:brew)
    TapDance.ui.error "You haven't installed homebrew, or it isn't in your path."
    exit 1
  end

  @definition = nil

  # Activate dry-run mode
  TapDance::BrewCLI.dry_run = options["dry-run"] if options["dry-run"]

  # Find brewfile
  @brewfile = options["brewfile"]
  @brewfile ||= "./Brewfile"
  @brewfile = File.expand_path @brewfile

  TapDance.ui.info "Brewing from #{@brewfile}"

  unless File.exist? @brewfile
    TapDance.ui.error "Nothing to brew! No Brewfile found."
  else
    TapDance.ui.info "Running `brew update` for good measure."
    BrewCLI.update
  end
end

Instance Attribute Details

#brewfileObject

Returns the value of attribute brewfile.



25
26
27
# File 'lib/tap_dance/cli.rb', line 25

def brewfile
  @brewfile
end

#definitionObject

Returns the value of attribute definition.



26
27
28
# File 'lib/tap_dance/cli.rb', line 26

def definition
  @definition
end

Instance Method Details

#installObject



62
63
64
65
66
# File 'lib/tap_dance/cli.rb', line 62

def install
  return unless File.exist? @brewfile
  @definition = TapDance::DSL.evaluate @brewfile
  @definition.execute
end

#update(name = nil) ⇒ Object



69
70
71
72
73
# File 'lib/tap_dance/cli.rb', line 69

def update(name=nil)
  return unless File.exist? @brewfile
  @definition = TapDance::DSL.evaluate @brewfile
  @definition.execute true
end