Module: Semaph::Commands

Defined in:
lib/semaph/commands.rb,
lib/semaph/commands/reload_command.rb,
lib/semaph/commands/visit_url_command.rb,
lib/semaph/commands/stop_workflow_command.rb,
lib/semaph/commands/rerun_workflow_command.rb

Defined Under Namespace

Classes: ReloadCommand, RerunWorkflowCommand, StopWorkflowCommand, VisitUrlCommand

Class Method Summary collapse

Class Method Details

.add_github_branch(shell, workflow) ⇒ Object



43
44
45
46
47
48
49
50
51
# File 'lib/semaph/commands.rb', line 43

def self.add_github_branch(shell, workflow)
  shell.add_command(
    ::Semaph::Commands::VisitUrlCommand.new(
      "#{workflow.project.github_url}/tree/#{workflow.branch}",
      "browse to the branch in github",
    ),
    "open-github-branch",
  )
end

.add_github_commands(shell, workflow) ⇒ Object



36
37
38
39
40
41
# File 'lib/semaph/commands.rb', line 36

def self.add_github_commands(shell, workflow)
  return unless workflow.project.github_url

  add_github_branch(shell, workflow)
  add_github_commit(shell, workflow)
end

.add_github_commit(shell, workflow) ⇒ Object



53
54
55
56
57
58
59
60
61
# File 'lib/semaph/commands.rb', line 53

def self.add_github_commit(shell, workflow)
  shell.add_command(
    ::Semaph::Commands::VisitUrlCommand.new(
      "#{workflow.project.github_url}/commit/#{workflow.sha}",
      "browse to the commit in github",
    ),
    "open-github-commit",
  )
end

.add_open_branch_command(shell, workflow) ⇒ Object



26
27
28
29
30
31
32
33
34
# File 'lib/semaph/commands.rb', line 26

def self.add_open_branch_command(shell, workflow)
  shell.add_command(
    ::Semaph::Commands::VisitUrlCommand.new(
      "https://#{workflow.project.client.host}/branches/#{workflow.branch_id}",
      "browse to branch in semaphore",
    ),
    "open-branch",
  )
end

.add_open_workflow_command(shell, workflow) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/semaph/commands.rb', line 16

def self.add_open_workflow_command(shell, workflow)
  shell.add_command(
    ::Semaph::Commands::VisitUrlCommand.new(
      "https://#{workflow.project.client.host}/workflows/#{workflow.id}",
      "browse to workflow",
    ),
    "open-workflow",
  )
end

.workflow_commands(shell, workflow) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/semaph/commands.rb', line 8

def self.workflow_commands(shell, workflow)
  shell.add_command ::Semaph::Commands::RerunWorkflowCommand.new(workflow), "rerun"
  shell.add_command ::Semaph::Commands::StopWorkflowCommand.new(workflow), "stop"
  add_open_workflow_command(shell, workflow)
  add_open_branch_command(shell, workflow)
  add_github_commands(shell, workflow)
end