Class: CircleCI::CLI::Command::WatchCommand

Inherits:
BaseCommand
  • Object
show all
Defined in:
lib/circleci/cli/command/watch_command.rb

Class Method Summary collapse

Methods inherited from BaseCommand

branch_name, build_number, project_name, setup_token

Class Method Details

.run(options) ⇒ Object

rubocop:disable Metrics/MethodLength



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/circleci/cli/command/watch_command.rb', line 11

def run(options) # rubocop:disable Metrics/MethodLength
  setup_token

  username, reponame = project_name(options).split('/')
  @options = options
  @repository = BuildRepository.new(
    username,
    reponame,
    branch: branch_name(options),
    user: options.user
  )
  @client = Networking::CircleCIPusherClient.new.tap(&:connect)
  @build_watcher = nil

  bind_status_event

  loop do
    stop_existing_watcher_if_needed
    start_watcher_if_needed
    sleep 1
  end
rescue Interrupt
  say 'Exited'
end