Class: GithubCLI::Commands::Labels

Inherits:
GithubCLI::Command show all
Defined in:
lib/github_cli/commands/labels.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

#add(user, repo, number, *args) ⇒ Object


80
81
82
83
84
85
# File 'lib/github_cli/commands/labels.rb', line 80

def add(user, repo, number, *args)
  global_options = options.dup
  params = options[:params].dup
  Util.hash_without!(global_options, params.keys + ['params'])
  Label.add user, repo, number, args, params, global_options
end

#create(user, repo) ⇒ Object


45
46
47
48
49
50
51
52
# File 'lib/github_cli/commands/labels.rb', line 45

def create(user, repo)
  global_options = options.dup
  params = options[:params].dup
  params['name']  = options[:name]  if options[:name]
  params['color'] = options[:color] if options[:color]
  Util.hash_without!(global_options, params.keys + ['params'])
  Label.create user, repo, params, global_options
end

#delete(user, repo, name) ⇒ Object


72
73
74
75
76
77
# File 'lib/github_cli/commands/labels.rb', line 72

def delete(user, repo, name)
  global_options = options.dup
  params = options[:params].dup
  Util.hash_without!(global_options, params.keys + ['params'])
  Label.delete user, repo, name, params, global_options
end

#get(user, repo, name) ⇒ Object


30
31
32
33
34
35
# File 'lib/github_cli/commands/labels.rb', line 30

def get(user, repo, name)
  global_options = options.dup
  params = options[:params].dup
  Util.hash_without!(global_options, params.keys + ['params'])
  Label.get user, repo, name, params, global_options
end

#list(user, repo) ⇒ Object


14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/github_cli/commands/labels.rb', line 14

def list(user, repo)
  global_options = options.dup
  params = options[:params].dup
  params_remove = params.keys + ['params']
  if (milestone_id = options[:milestone])
    params['milestone_id'] = milestone_id
    params_remove << 'milestone'
  elsif (issue_id = options[:issue])
    params['issue_id'] = issue_id
    params_remove << 'issue'
  end
  Util.hash_without!(global_options, params_remove)
  Label.all user, repo, params, global_options
end

#remove(user, repo, number) ⇒ Object


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

def remove(user, repo, number)
  name, number  = Arguments.new(number).parse
  global_options = options.dup
  params = options[:params].dup
  params['label_name'] = name if name
  Util.hash_without!(global_options, params.keys + ['params'])
  Label.remove user, repo, number, params, global_options
end

#replace(user, repo, number, *args) ⇒ Object


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

def replace(user, repo, number, *args)
  global_options = options.dup
  params = options[:params].dup
  Util.hash_without!(global_options, params.keys + ['params'])
  Label.replace user, repo, number, args, params, global_options
end

#update(user, repo, name) ⇒ Object


62
63
64
65
66
67
68
69
# File 'lib/github_cli/commands/labels.rb', line 62

def update(user, repo, name)
  global_options = options.dup
  params = options[:params].dup
  params['name']  = options[:name]  if options[:name]
  params['color'] = options[:color] if options[:color]
  Util.hash_without!(global_options, params.keys + ['params'])
  Label.update user, repo, name, params, global_options
end