Module: DTK::Client::RemotesMixin

Included in:
ModuleMixin
Defined in:
lib/commands/common/thor/remotes.rb

Instance Method Summary collapse

Instance Method Details

#remote_add_aux(context_params) ⇒ Object



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/commands/common/thor/remotes.rb', line 41

def remote_add_aux(context_params)
  module_id, remote_name, remote_url = context_params.retrieve_arguments([::DTK::Client::ModuleMixin::REQ_MODULE_ID,:option_1!,:option_2!], method_argument_names)
  module_type = get_module_type(context_params)

  post_body = {
    "#{module_type}_id".to_sym => module_id,
    :remote_name => remote_name,
    :remote_url  => remote_url
  }

  response = post rest_url("#{module_type}/add_git_remote"), post_body
  return response unless response.ok?
  OsUtil.print("Successfully added remote '#{remote_name}'", :green)
  nil
end

#remote_list_aux(context_params) ⇒ Object



57
58
59
60
61
62
63
64
65
66
67
# File 'lib/commands/common/thor/remotes.rb', line 57

def remote_list_aux(context_params)
  module_id   = context_params.retrieve_arguments([::DTK::Client::ModuleMixin::REQ_MODULE_ID], method_argument_names)
  module_type = get_module_type(context_params)

  post_body = {
    "#{module_type}_id".to_sym => module_id
  }

  response = post rest_url("#{module_type}/info_git_remote"), post_body
  response.render_table(:remotes)
end

#remote_remove_aux(context_params) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/commands/common/thor/remotes.rb', line 22

def remote_remove_aux(context_params)
  module_id, remote_name = context_params.retrieve_arguments([::DTK::Client::ModuleMixin::REQ_MODULE_ID,:option_1!], method_argument_names)
  module_type = get_module_type(context_params)

  unless options.force
    return unless Console.confirmation_prompt("Are you sure you want to remove '#{remote_name}'?")
  end

  post_body = {
    "#{module_type}_id".to_sym => module_id,
    :remote_name => remote_name
  }

  response = post rest_url("#{module_type}/remove_git_remote"), post_body
  return response unless response.ok?
  OsUtil.print("Successfully removed remote '#{remote_name}'", :green)
  nil
end