Class: Greenhouse::Commands::Push

Inherits:
Object
  • Object
show all
Includes:
Command
Defined in:
lib/greenhouse/commands/push.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Command

included

Class Method Details

.usageObject



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/greenhouse/commands/push.rb', line 10

def usage
  puts <<USAGE
usage: #{::Greenhouse::CLI.command_name} #{command_name} [<project>] #{valid_arguments.to_s}

Arguments:
#{valid_arguments.to_help}

Projects:
#{project_arguments.to_help}
USAGE
end

Instance Method Details

#force?Boolean

Returns:

  • (Boolean)


23
24
25
# File 'lib/greenhouse/commands/push.rb', line 23

def force?
  arguments.map(&:key).include?("-f")
end

#push_allObject



27
28
29
30
31
32
33
34
35
36
# File 'lib/greenhouse/commands/push.rb', line 27

def push_all
  if Projects.projects.empty?
    puts "No projects defined."
    return
  end

  Projects.projects.each do |project|
    Tasks::PushProject.perform(project, force?)
  end
end

#push_project(project) ⇒ Object



38
39
40
41
42
43
44
45
# File 'lib/greenhouse/commands/push.rb', line 38

def push_project(project)
  unless project.exists?
    puts "Project #{project.title.cyan} does not exist. Try initializing it with `greenhouse init`"
    return
  end

  Tasks::PushProject.perform(project, force?)
end

#runObject



47
48
49
50
# File 'lib/greenhouse/commands/push.rb', line 47

def run
  project = Projects::projects.select { |project| arguments.map(&:key).include?(project.name) }.first
  project.nil? ? push_all : push_project(project)
end