Class: Hooker::CLI

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

Instance Method Summary collapse

Instance Method Details

#ensure_hooksObject



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/hooker/cli.rb', line 43

def ensure_hooks
  hook_url = options[:hook_url]
  events = options[:events]
  if hook_url.nil? || events.nil?
    puts 'Please provide --hook_url <url> and --events <comma,separated,events>'
    exit 1
  end
  events = events.split(',')
  if events.empty?
    puts 'Please provide --events <comma,separated,events>'
    exit 1
  end
  if repo = options[:repo]
    ensure_hook(repo, hook_url, events)
  else
    repos = ::Hooker::Repos.list(options).map(&:full_name).sort
    repos.each { |r| ensure_hook(r, hook_url, events) }
  end
end

#hooksObject



27
28
29
30
31
32
33
34
# File 'lib/hooker/cli.rb', line 27

def hooks
  if repo = options[:repo]
    print_hooks(repo)
  else
    repos = ::Hooker::Repos.list(options).map(&:full_name).sort
    repos.each { |r| print_hooks(r) }
  end
end

#reposObject



18
19
20
# File 'lib/hooker/cli.rb', line 18

def repos
  puts ::Hooker::Repos.list(options).map(&:full_name).sort.join("\n")
end

#versionObject



10
11
12
# File 'lib/hooker/cli.rb', line 10

def version
  puts "Hooker version #{::Hooker::VERSION}"
end