Class: GithubCLI::Commands::Gists

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

#createObject


53
54
55
56
57
58
59
60
61
# File 'lib/github_cli/commands/gists.rb', line 53

def create
  global_options = options.dup
  params = options[:params].dup
  params['description'] = options[:desc] if options[:desc]
  params['public'] = options[:public] || false
  params['files']  = options[:files] if options[:files]
  Util.hash_without!(global_options, params.keys + ['params', 'desc'])
  Gist.create params, global_options
end

#delete(id) ⇒ Object


119
120
121
122
123
124
# File 'lib/github_cli/commands/gists.rb', line 119

def delete(id)
  global_options = options.dup
  params = options[:params].dup
  Util.hash_without!(global_options, params.keys + ['params', 'desc'])
  Gist.delete id, params, global_options
end

#edit(id) ⇒ Object


77
78
79
80
81
82
83
84
# File 'lib/github_cli/commands/gists.rb', line 77

def edit(id)
  global_options = options.dup
  params = options[:params].dup
  params['description'] = options[:desc] if options[:desc]
  params['files'] = options[:files] if options[:files]
  Util.hash_without!(global_options, params.keys + ['params', 'desc'])
  Gist.edit id, params, global_options
end

#fork(id) ⇒ Object


111
112
113
114
115
116
# File 'lib/github_cli/commands/gists.rb', line 111

def fork(id)
  global_options = options.dup
  params = options[:params].dup
  Util.hash_without!(global_options, params.keys + ['params', 'desc'])
  Gist.fork id, params, global_options
end

#get(id) ⇒ Object


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

def get(id)
  global_options = options.dup
  params = options[:params].dup
  Util.hash_without!(global_options, params.keys + ['params'])
  Gist.get id, params, global_options
end

#listObject


17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/github_cli/commands/gists.rb', line 17

def list
  global_options = options.dup
  params = options[:params].dup
  if options[:starred]
    Util.hash_without!(global_options, params.keys + ['params', 'starred'])
    Gist.starred params, global_options
  else
    params['user'] = options[:user] if options[:user]
    Util.hash_without!(global_options, params.keys + ['params', 'user'])
    Gist.all params, global_options
  end
end

#star(id) ⇒ Object


87
88
89
90
91
92
# File 'lib/github_cli/commands/gists.rb', line 87

def star(id)
  global_options = options.dup
  params = options[:params].dup
  Util.hash_without!(global_options, params.keys + ['params', 'desc'])
  Gist.star id, params, global_options
end

#starred(id) ⇒ Object


103
104
105
106
107
108
# File 'lib/github_cli/commands/gists.rb', line 103

def starred(id)
  global_options = options.dup
  params = options[:params].dup
  Util.hash_without!(global_options, params.keys + ['params', 'desc'])
  Gist.starred? id, params, global_options
end

#unstar(id) ⇒ Object


95
96
97
98
99
100
# File 'lib/github_cli/commands/gists.rb', line 95

def unstar(id)
  global_options = options.dup
  params = options[:params].dup
  Util.hash_without!(global_options, params.keys + ['params', 'desc'])
  Gist.unstar id, params, global_options
end