Class: Vendor::CLI::App

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

Defined Under Namespace

Classes: Library

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeApp

Returns a new instance of App.



58
59
60
61
62
63
# File 'lib/vendor/cli/app.rb', line 58

def initialize(*)
  super
  the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
  Vendor.ui = UI::Shell.new(the_shell)
  Vendor.ui.debug! if options["verbose"]
end

Class Method Details

.exit_on_failure?Boolean

Exit with 1 if thor encounters an error (such as command missing)

Returns:

  • (Boolean)


132
133
134
# File 'lib/vendor/cli/app.rb', line 132

def self.exit_on_failure?
  true
end

Instance Method Details

#authObject



109
110
111
112
113
114
115
116
117
# File 'lib/vendor/cli/app.rb', line 109

def auth
  begin
    Vendor::CLI::Auth.with_api_key do |api_key|
      Vendor.ui.success "Successfully authenticated"
    end
  rescue Vendor::API::Error => e
    Vendor.ui.error "Error: #{e.message}"
  end
end

#consoleObject



120
121
122
123
124
# File 'lib/vendor/cli/app.rb', line 120

def console
  # Need to clear the arguments otherwise they are passed through to RIPL
  ARGV.clear
  Ripl.start :binding => Vendor::CLI::Console.instance_eval{ binding }
end

#initObject



104
105
106
# File 'lib/vendor/cli/app.rb', line 104

def init
  Vendor::Template.copy "Vendorfile"
end

#installObject



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# File 'lib/vendor/cli/app.rb', line 74

def install
  vendorfile = File.expand_path("Vendorfile")

  unless File.exist?(vendorfile)
    Vendor.ui.error "Could not find Vendorfile"
    exit 1
  end

  projects = Dir["*.xcodeproj"]

  if projects.length > 1
    Vendor.ui.error "Mutiple projects found #{projects.join(', ')}. I don't know how to deal with this yet."
    exit 1
  end

  project = Vendor::XCode::Project.new(projects.first)

  loader = Vendor::VendorFile::Loader.new
  loader.load vendorfile
  loader.install project

  if project.dirty?
    project.save
    Vendor.ui.success "Finished installing into #{project.name}"
  else
    Vendor.ui.info "No changes were made to #{project.name}"
  end
end

#versionObject



127
128
129
# File 'lib/vendor/cli/app.rb', line 127

def version
  Vendor.ui.info Vendor.version
end