Class: GithubCLI::Commands::Repositories

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

#branch(user, repo, name) ⇒ Object


164
165
166
167
168
169
# File 'lib/github_cli/commands/repositories.rb', line 164

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

#branches(user, repo) ⇒ Object


156
157
158
159
160
161
# File 'lib/github_cli/commands/repositories.rb', line 156

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

#contribs(user, repo) ⇒ Object


172
173
174
175
176
177
# File 'lib/github_cli/commands/repositories.rb', line 172

def contribs(user, repo)
  global_options = options.dup
  params = options[:params].dup
  Util.hash_without!(global_options, params.keys + ['params'])
  Repository.contributors user, repo, params, global_options
end

#create(args) ⇒ Object


81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/github_cli/commands/repositories.rb', line 81

def create(args)
  global_options = options.dup
  params = options[:params].dup
  org, params['name'] = Arguments.new(args).parse
  params['org']                = org if org
  params['org']                = options[:org]       if options[:org]
  params['description']        = options[:desc]      if options[:desc]
  params['homepage']           = options[:home]      if options[:home]
  params['private']            = options[:private]
  params['has_issues']         = options[:issues]
  params['has_wiki']           = options[:wiki]
  params['has_downloads']      = options[:downloads]
  params['team_id']            = options[:team]      if options[:team]
  params['auto_init']          = options[:auto]
  params['gitignore_template'] = options[:gitignore] if options[:gitignore]

  Util.hash_without!(global_options,
    params.keys + %w[ params issues wiki downloads team auto gitignore ])
  Repository.create params, global_options
end

#delete(user, repo) ⇒ Object


148
149
150
151
152
153
# File 'lib/github_cli/commands/repositories.rb', line 148

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

#edit(user, repo, name) ⇒ Object


130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'lib/github_cli/commands/repositories.rb', line 130

def edit(user, repo, name)
  global_options = options.dup
  params = options[:params].dup
  params['name'] = name
  params['description']    = options[:desc]      if options[:desc]
  params['homepage']       = options[:home]      if options[:home]
  params['private']        = options[:private]
  params['has_issues']     = options[:issues]
  params['has_wiki']       = options[:wiki]
  params['has_downloads']  = options[:downloads]
  params['default_branch'] = options[:branch]    if options[:branch]

  Util.hash_without!(global_options,
    params.keys + %w[ wiki issues downloads params] )
  Repository.edit user, repo, params, global_options
end

#get(user, repo) ⇒ Object


37
38
39
40
41
42
# File 'lib/github_cli/commands/repositories.rb', line 37

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

#langs(user, repo) ⇒ Object


180
181
182
183
184
185
# File 'lib/github_cli/commands/repositories.rb', line 180

def langs(user, repo)
  global_options = options.dup
  params = options[:params].dup
  Util.hash_without!(global_options, params.keys + ['params'])
  Repository.languages user, repo, params, global_options
end

#listObject


23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/github_cli/commands/repositories.rb', line 23

def list
  global_options = options.dup
  params = options[:params].dup
  params['org']   = options[:org]   if options[:org]
  params['user']  = options[:user]  if options[:user]
  params['since'] = options[:since] if options[:since]
  params['type']  = options[:type]  if options[:type]
  params['sort']  = options[:sort]  if options[:sort]
  params['direction'] = options[:direction] if options[:direction]
  Util.hash_without!(global_options, params.keys + ['params'])
  Repository.all params, global_options
end

#tags(user, repo) ⇒ Object


188
189
190
191
192
193
# File 'lib/github_cli/commands/repositories.rb', line 188

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

#teams(user, repo) ⇒ Object


196
197
198
199
200
201
# File 'lib/github_cli/commands/repositories.rb', line 196

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