Class: GithubCLI::Commands::Hooks

Inherits:
GithubCLI::Command show all
Defined in:
lib/github_cli/commands/hooks.rb

Constant Summary

Constants inherited from GithubCLI::Command

GithubCLI::Command::ALIASES, GithubCLI::Command::HELP_COMMAND

Constants inherited from Thor

Thor::DynamicTask, Thor::HELP_MAPPINGS, Thor::HiddenTask, Thor::THOR_RESERVED_WORDS, Thor::Task, Thor::UndefinedTaskError, Thor::VERSION

Instance Attribute Summary

Attributes included from Thor::Actions

#behavior

Attributes included from Thor::Base

#args, #options, #parent_options

Instance Method Summary collapse

Methods inherited from GithubCLI::Command

all, command_to_show, extract_namespace, is_api_command?, output_formats

Methods included from Thor::Actions

#action, #append_to_file, #apply, #chmod, #comment_lines, #copy_file, #create_file, #create_link, #destination_root, #destination_root=, #directory, #empty_directory, #find_in_source_paths, #gsub_file, #in_root, included, #initialize, #inject_into_class, #insert_into_file, #inside, #link_file, #prepend_to_file, #relative_to_original_destination_root, #remove_file, #run, #run_ruby_script, #source_paths, #template, #thor, #uncomment_lines

Methods inherited from Thor

check_unknown_options!, check_unknown_options?, command_help, default_command, desc, global_flags, handle_no_task_error, help, #help, long_desc, map, method_option, method_options, package_name, printable_commands, register, stop_on_unknown_option!, stop_on_unknown_option?, subcommand, subcommands

Methods included from Thor::Base

included, #initialize, register_klass_file, shell, shell=, subclass_files, subclasses

Instance Method Details

#create(user, repo) ⇒ Object


41
42
43
44
45
46
47
48
49
50
# File 'lib/github_cli/commands/hooks.rb', line 41

def create(user, repo)
  global_options = options.dup
  params = options[:params].dup
  params['name']   = options[:name]
  params['config'] = options[:config]
  params['events'] = options[:events] if options[:events]
  params['active'] = options[:active] if options[:active]
  Util.hash_without!(global_options, %w[ params name config events active ])
  Hook.create user, repo, params, global_options
end

#delete(user, repo, id) ⇒ Object


97
98
99
100
101
102
# File 'lib/github_cli/commands/hooks.rb', line 97

def delete(user, repo, id)
  global_options = options.dup
  params = options[:params].dup
  Util.hash_without!(global_options, %w[ params ])
  Hook.delete user, repo, id, params, global_options
end

#edit(user, repo, id) ⇒ Object


75
76
77
78
79
80
81
82
83
84
85
86
# File 'lib/github_cli/commands/hooks.rb', line 75

def edit(user, repo, id)
  global_options = options.dup
  params = options[:params].dup
  params['name']          = options[:name]
  params['config']        = options[:config]
  params['events']        = options[:events]        if options[:events]
  params['add_events']    = options[:add_events]    if options[:add_events]
  params['remove_events'] = options[:remove_events] if options[:remove_events]
  params['active']        = options[:active]        if options[:active]
  Util.hash_without!(global_options, params.keys + ['params'])
  Hook.edit user, repo, id, params, global_options
end

#get(user, repo, id) ⇒ Object


17
18
19
20
21
22
# File 'lib/github_cli/commands/hooks.rb', line 17

def get(user, repo, id)
  global_options = options.dup
  params = options[:params].dup
  Util.hash_without!(global_options, %w[ params ])
  Hook.get user, repo, id, params, global_options
end

#list(user, repo) ⇒ Object


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

def list(user, repo)
  global_options = options.dup
  params = options[:params].dup
  Util.hash_without!(global_options, %w[ params ])
  Hook.all user, repo, params, global_options
end

#test(user, repo, id) ⇒ Object


89
90
91
92
93
94
# File 'lib/github_cli/commands/hooks.rb', line 89

def test(user, repo, id)
  global_options = options.dup
  params = options[:params].dup
  Util.hash_without!(global_options, %w[ params ])
  Hook.test user, repo, id, params, global_options
end