epc 1.0.4 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (194) hide show
  1. data/lib/epc.rb +3 -0
  2. data/lib/epc/client/base_client.rb +2 -1
  3. data/lib/epc/client/json_client.rb +22 -0
  4. data/lib/epc/command/archive_command.rb +1 -1
  5. data/lib/epc/command/attachto_command.rb +1 -1
  6. data/lib/epc/command/base_command.rb +35 -25
  7. data/lib/epc/command/build_command.rb +2 -2
  8. data/lib/epc/command/config/create_config_command.rb +1 -1
  9. data/lib/epc/command/config/delete_config_command.rb +4 -4
  10. data/lib/epc/command/config/list_configs_command.rb +1 -1
  11. data/lib/epc/command/config/update_config_command.rb +3 -3
  12. data/lib/epc/command/copy_command.rb +1 -1
  13. data/lib/epc/command/create_command.rb +1 -1
  14. data/lib/epc/command/delete_command.rb +2 -2
  15. data/lib/epc/command/deploy_command.rb +4 -3
  16. data/lib/epc/command/deployment/copy_deployment_command.rb +1 -1
  17. data/lib/epc/command/deployment/create_deployment_command.rb +3 -3
  18. data/lib/epc/command/deployment/list_deployments_command.rb +1 -1
  19. data/lib/epc/command/deployment/show_deployment_command.rb +1 -1
  20. data/lib/epc/command/deployment/submit_deployment_command.rb +1 -1
  21. data/lib/epc/command/deployment/update_deployment_command.rb +1 -1
  22. data/lib/epc/command/deployment/vote_deployment_command.rb +1 -1
  23. data/lib/epc/command/deploymentstage/list_deploymentstages_command.rb +1 -1
  24. data/lib/epc/command/detachfrom_command.rb +1 -1
  25. data/lib/epc/command/group/create_group_command.rb +1 -1
  26. data/lib/epc/command/group/delete_group_command.rb +1 -1
  27. data/lib/epc/command/group/list_groups_command.rb +1 -1
  28. data/lib/epc/command/group/show_group_command.rb +2 -1
  29. data/lib/epc/command/group/update_group_command.rb +1 -1
  30. data/lib/epc/command/library/create_library_command.rb +2 -2
  31. data/lib/epc/command/library/delete_library_command.rb +1 -1
  32. data/lib/epc/command/library/list_libraries_command.rb +1 -1
  33. data/lib/epc/command/librarylanguage/create_librarylanguage_command.rb +1 -1
  34. data/lib/epc/command/librarylanguage/delete_librarylanguage_command.rb +1 -1
  35. data/lib/epc/command/librarylanguage/list_librarylanguages_command.rb +1 -1
  36. data/lib/epc/command/librarylanguage/update_librarylanguage_command.rb +1 -1
  37. data/lib/epc/command/libraryset/create_libraryset_command.rb +2 -2
  38. data/lib/epc/command/libraryset/delete_libraryset_command.rb +1 -1
  39. data/lib/epc/command/libraryset/list_librarysets_command.rb +1 -1
  40. data/lib/epc/command/libraryset/show_libraryset_command.rb +1 -1
  41. data/lib/epc/command/libraryset/update_libraryset_command.rb +3 -3
  42. data/lib/epc/command/list_command.rb +1 -1
  43. data/lib/epc/command/objectrole/create_objectrole_command.rb +2 -1
  44. data/lib/epc/command/objectrole/list_objectroles_command.rb +1 -1
  45. data/lib/epc/command/objectrole/update_objectrole_command.rb +5 -1
  46. data/lib/epc/command/permission/list_permissions_command.rb +1 -1
  47. data/lib/epc/command/permissiongroup/list_permissiongroups_command.rb +1 -1
  48. data/lib/epc/command/plugin/create_plugin_command.rb +1 -1
  49. data/lib/epc/command/plugin/delete_plugin_command.rb +1 -1
  50. data/lib/epc/command/plugin/list_plugins_command.rb +1 -1
  51. data/lib/epc/command/plugin/show_plugin_command.rb +1 -1
  52. data/lib/epc/command/plugin/update_plugin_command.rb +2 -2
  53. data/lib/epc/command/project/archive_project_command.rb +1 -1
  54. data/lib/epc/command/project/attachto_project_command.rb +3 -3
  55. data/lib/epc/command/project/create_project_command.rb +2 -2
  56. data/lib/epc/command/project/delete_project_command.rb +1 -1
  57. data/lib/epc/command/project/detachfrom_project_command.rb +4 -4
  58. data/lib/epc/command/project/list_projects_command.rb +1 -1
  59. data/lib/epc/command/project/show_project_command.rb +2 -1
  60. data/lib/epc/command/project/unarchive_project_command.rb +1 -2
  61. data/lib/epc/command/project/update_project_command.rb +2 -2
  62. data/lib/epc/command/projecttype/create_projecttype_command.rb +3 -3
  63. data/lib/epc/command/projecttype/delete_projecttype_command.rb +2 -1
  64. data/lib/epc/command/projecttype/list_projecttypes_command.rb +1 -1
  65. data/lib/epc/command/projecttype/show_projecttype_command.rb +2 -1
  66. data/lib/epc/command/projecttype/update_projecttype_command.rb +4 -3
  67. data/lib/epc/command/pull_command.rb +12 -10
  68. data/lib/epc/command/push_command.rb +45 -29
  69. data/lib/epc/command/role/create_role_command.rb +1 -1
  70. data/lib/epc/command/role/delete_role_command.rb +2 -1
  71. data/lib/epc/command/role/list_roles_command.rb +2 -5
  72. data/lib/epc/command/role/show_role_command.rb +2 -2
  73. data/lib/epc/command/role/update_role_command.rb +1 -1
  74. data/lib/epc/command/runtime/create_runtime_command.rb +1 -1
  75. data/lib/epc/command/runtime/delete_runtime_command.rb +2 -1
  76. data/lib/epc/command/runtime/list_runtimes_command.rb +1 -1
  77. data/lib/epc/command/runtime/update_runtime_command.rb +4 -3
  78. data/lib/epc/command/runtimetype/list_runtimetypes_command.rb +1 -1
  79. data/lib/epc/command/servicedefinition/create_servicedefinition_command.rb +2 -2
  80. data/lib/epc/command/servicedefinition/delete_servicedefinition_command.rb +1 -1
  81. data/lib/epc/command/servicedefinition/list_servicedefinitions_command.rb +1 -1
  82. data/lib/epc/command/servicetype/list_servicetypes_command.rb +1 -1
  83. data/lib/epc/command/serviceversion/create_serviceversion_command.rb +2 -2
  84. data/lib/epc/command/serviceversion/delete_serviceversion_command.rb +3 -1
  85. data/lib/epc/command/serviceversion/list_serviceversions_command.rb +1 -1
  86. data/lib/epc/command/show_command.rb +1 -1
  87. data/lib/epc/command/solution/archive_solution_command.rb +1 -1
  88. data/lib/epc/command/solution/create_solution_command.rb +2 -2
  89. data/lib/epc/command/solution/delete_solution_command.rb +1 -1
  90. data/lib/epc/command/solution/list_solutions_command.rb +1 -1
  91. data/lib/epc/command/solution/show_solution_command.rb +1 -1
  92. data/lib/epc/command/solution/unarchive_solution_command.rb +1 -1
  93. data/lib/epc/command/solution/update_solution_command.rb +1 -1
  94. data/lib/epc/command/submit_command.rb +1 -1
  95. data/lib/epc/command/unarchive_command.rb +1 -1
  96. data/lib/epc/command/update_command.rb +1 -1
  97. data/lib/epc/command/user/create_user_command.rb +1 -1
  98. data/lib/epc/command/user/delete_user_command.rb +1 -1
  99. data/lib/epc/command/user/list_users_command.rb +1 -1
  100. data/lib/epc/command/user/show_user_command.rb +2 -1
  101. data/lib/epc/command/user/update_user_command.rb +3 -3
  102. data/lib/epc/command/userproperty/delete_user_property_command.rb +48 -0
  103. data/lib/epc/command/userproperty/get_user_property_command.rb +61 -0
  104. data/lib/epc/command/userproperty/list_user_properties_command.rb +1 -1
  105. data/lib/epc/command/userproperty/set_user_property_command.rb +52 -0
  106. data/lib/epc/command/vote_command.rb +1 -1
  107. data/lib/epc/config.rb +12 -0
  108. data/lib/epc/help.rb +20 -8
  109. data/lib/epc/runner.rb +22 -11
  110. data/lib/epc/version.rb +1 -1
  111. data/test/command/archive_project_command_test.rb +1 -1
  112. data/test/command/archive_solution_command_test.rb +1 -1
  113. data/test/command/build_command_test.rb +1 -1
  114. data/test/command/copy_deployment_command_test.rb +1 -1
  115. data/test/command/create_config_command_test.rb +1 -1
  116. data/test/command/create_deployment_command_test.rb +3 -3
  117. data/test/command/create_group_command_test.rb +1 -1
  118. data/test/command/create_library_command_test.rb +1 -1
  119. data/test/command/create_librarylanguage_command_test.rb +2 -2
  120. data/test/command/create_libraryset_command_test.rb +2 -2
  121. data/test/command/create_objectrole_command_test.rb +1 -1
  122. data/test/command/create_project_command_test.rb +2 -2
  123. data/test/command/create_projecttypes_command_test.rb +33 -0
  124. data/test/command/create_role_command_test.rb +10 -1
  125. data/test/command/create_runtime_command_test.rb +1 -1
  126. data/test/command/create_servicedefinition_command_test.rb +1 -1
  127. data/test/command/create_serviceversion_command_test.rb +1 -1
  128. data/test/command/create_solution_command_test.rb +2 -2
  129. data/test/command/create_user_command_test.rb +1 -1
  130. data/test/command/delete_config_command_test.rb +3 -3
  131. data/test/command/delete_library_command_test.rb +1 -1
  132. data/test/command/delete_librarylanguage_command_test.rb +1 -1
  133. data/test/command/delete_libraryset_command_test.rb +1 -1
  134. data/test/command/delete_plugin_command_test.rb +1 -1
  135. data/test/command/delete_project_command_test.rb +1 -1
  136. data/test/command/delete_projecttype_command_test.rb +1 -1
  137. data/test/command/delete_role_command_test.rb +1 -1
  138. data/test/command/delete_runtime_command_test.rb +1 -1
  139. data/test/command/delete_servicedefinition_command_test.rb +1 -1
  140. data/test/command/delete_serviceversion_command_test.rb +1 -1
  141. data/test/command/delete_solution_command_test.rb +1 -1
  142. data/test/command/delete_user_command_test.rb +1 -1
  143. data/test/command/delete_user_property_command_test.rb +60 -0
  144. data/test/command/deploy_command_test.rb +14 -6
  145. data/test/command/get_user_property_command_test.rb +58 -0
  146. data/test/command/list_command_test.rb +28 -0
  147. data/test/command/list_config_command_test.rb +1 -1
  148. data/test/command/list_deployments_command_test.rb +1 -1
  149. data/test/command/list_deploymentstages_command_test.rb +1 -1
  150. data/test/command/list_libraries_command_test.rb +1 -1
  151. data/test/command/list_librarylanguages_command_test.rb +1 -1
  152. data/test/command/list_librarysets_command_test.rb +1 -1
  153. data/test/command/list_objectroles_command_test.rb +1 -1
  154. data/test/command/list_permissiongroups_command_test.rb +1 -1
  155. data/test/command/list_permissions_command_test.rb +1 -1
  156. data/test/command/list_plugins_command_test.rb +1 -1
  157. data/test/command/list_projects_command_test.rb +1 -1
  158. data/test/command/list_projecttypes_command_test.rb +1 -1
  159. data/test/command/list_roles_command_test.rb +9 -1
  160. data/test/command/list_runtimes_command_test.rb +1 -1
  161. data/test/command/list_runtimetypes_command_test.rb +1 -1
  162. data/test/command/list_service_types_command_test.rb +1 -1
  163. data/test/command/list_servicedefinitions_command_test.rb +1 -1
  164. data/test/command/list_serviceversions_command_test.rb +1 -1
  165. data/test/command/list_solutions_command_test.rb +1 -1
  166. data/test/command/list_userproperties_command_test.rb +3 -3
  167. data/test/command/list_users_command_test.rb +1 -1
  168. data/test/command/pull_command_test.rb +8 -8
  169. data/test/command/push_command_test.rb +38 -8
  170. data/test/command/set_user_property_command_test.rb +50 -0
  171. data/test/command/show_command_test.rb +28 -0
  172. data/test/command/show_deployment_command_test.rb +1 -1
  173. data/test/command/show_group_command_test.rb +1 -1
  174. data/test/command/show_libraryset_command_test.rb +1 -1
  175. data/test/command/show_plugin_command_test.rb +1 -1
  176. data/test/command/show_project_command_test.rb +1 -1
  177. data/test/command/show_projecttype_command_test.rb +1 -1
  178. data/test/command/show_role_command_test.rb +1 -1
  179. data/test/command/show_solution_command_test.rb +1 -1
  180. data/test/command/show_user_command_test.rb +1 -1
  181. data/test/command/submit_deployment_command_test.rb +1 -1
  182. data/test/command/unarchive_project_command_test.rb +1 -1
  183. data/test/command/unarchive_solution_command_test.rb +1 -1
  184. data/test/command/update_config_command_test.rb +2 -2
  185. data/test/command/update_deployment_command_test.rb +1 -1
  186. data/test/command/update_group_command_test.rb +1 -1
  187. data/test/command/update_librarylanguage_command_test.rb +1 -1
  188. data/test/command/update_libraryset_command_test.rb +3 -3
  189. data/test/command/update_plugin_command_test.rb +2 -2
  190. data/test/command/update_project_command_test.rb +2 -2
  191. data/test/command/update_solution_command_test.rb +1 -1
  192. data/test/command/update_user_command_test.rb +2 -2
  193. data/test/command/vote_deployment_command_test.rb +1 -1
  194. metadata +38 -23
@@ -22,7 +22,7 @@ module EPC::Command
22
22
  status, response, headers = client.get(EPC::Config::SOLUTIONS_PATH + "/#{solution_id}/projects#{include}")
23
23
 
24
24
  if status.failure?
25
- say("Projects retrieval failed with [#{response[:message]}]")
25
+ say_err("Projects retrieval failed with [#{response[:message]}]")
26
26
  elsif response.empty?
27
27
  say("You have no projects created. You can create them with epc create project.")
28
28
  else
@@ -4,6 +4,7 @@ module EPC::Command
4
4
 
5
5
 
6
6
  def execute(args = [])
7
+ require_object
7
8
  @showable_translations = {
8
9
  :config => :config_values,
9
10
  :services => :service_versions,
@@ -14,7 +15,7 @@ module EPC::Command
14
15
 
15
16
  status, response, message = client.get(EPC::Config::PROJECTS_PATH + "/#{object_id}?include=dependencies,roles,config_values,service_versions,libraries,pushed_versions")
16
17
  if status.failure?
17
- say("Request failed: [#{response[:message]}]")
18
+ say_err("Request failed: [#{response[:message]}]")
18
19
  return status
19
20
  end
20
21
 
@@ -8,10 +8,9 @@ module EPC::Command
8
8
  if status.successful?
9
9
  say("Project has been unarchived.")
10
10
  else
11
- say("Project could not be unarchived. Request failed with: [#{response[:message]}]")
11
+ say_err("Project could not be unarchived. Request failed with: [#{response[:message]}]")
12
12
  end
13
13
  return status
14
14
  end
15
15
  end
16
16
  end
17
-
@@ -20,14 +20,14 @@ module EPC::Command
20
20
  args_hash.each do |attr, val|
21
21
  unless UPDATABLE_ATTRIBUTES.include?(attr)
22
22
  args_hash.delete(attr)
23
- say("Cannot update #{attr}. Updatable attributes are: [#{UPDATABLE_ATTRIBUTES.join(', ')}]")
23
+ say_err("Cannot update #{attr}. Updatable attributes are: [#{UPDATABLE_ATTRIBUTES.join(', ')}]")
24
24
  next
25
25
  end
26
26
  end
27
27
  unless args_hash.empty?
28
28
  status, response, message = client.put(EPC::Config::PROJECTS_PATH + "/#{object_id}", args_hash)
29
29
  if status.failure?
30
- say("Update failed with: [#{response[:message]}]")
30
+ say_err("Update failed with: [#{response[:message]}]")
31
31
  else
32
32
  say("Update succesful")
33
33
  end
@@ -2,7 +2,7 @@ module EPC::Command
2
2
  class CreateProjecttypeCommand < CreateCommand
3
3
 
4
4
  def execute(args = [])
5
- # raise FatalError, "You need to specify all mandatory parameters" if args.size < 5
5
+ raise FatalError, "You need to specify all mandatory parameters" if args.size < 5
6
6
 
7
7
  params = {}
8
8
  params[:name] = args[0]
@@ -18,7 +18,7 @@ module EPC::Command
18
18
  params[:runtime_env_types] << {:id => retrieve_identifier_for("RuntimeEnvType", rti)}
19
19
  end
20
20
  rescue Exception => ex
21
- say("Unable to parse runtime-env-types parameter")
21
+ say_err("Unable to parse runtime-env-types parameter")
22
22
  return 1
23
23
  end
24
24
 
@@ -27,7 +27,7 @@ module EPC::Command
27
27
  if status.successful?
28
28
  say("ProjectType [#{args[0]}] created")
29
29
  else
30
- say("Request failed: [#{response[:message]}]")
30
+ say_err("Request failed: [#{response[:message]}]")
31
31
  end
32
32
 
33
33
  return status
@@ -2,6 +2,7 @@ module EPC::Command
2
2
  class DeleteProjecttypeCommand < DeleteCommand
3
3
 
4
4
  def execute(args = [])
5
+ require_object
5
6
 
6
7
  proceed = ask_yn("Are you sure you want to delete the [#{object_id}] ProjectType? [Yn] ")
7
8
  if proceed.upcase == 'N'
@@ -13,7 +14,7 @@ module EPC::Command
13
14
  if status.successful?
14
15
  say("Project type deleted")
15
16
  else
16
- say("Request failed: [#{response[:message]}]")
17
+ say_err("Request failed: [#{response[:message]}]")
17
18
  end
18
19
 
19
20
  return status
@@ -5,7 +5,7 @@ module EPC::Command
5
5
  status, response, headers = client.get(EPC::Config::PROJECT_TYPES_PATH)
6
6
 
7
7
  if status.failure?
8
- say("Request failed: [#{response[:message]}]")
8
+ say_err("Request failed: [#{response[:message]}]")
9
9
  elsif response.empty?
10
10
  say("No project types defined")
11
11
  else
@@ -2,11 +2,12 @@ module EPC::Command
2
2
  class ShowProjecttypeCommand < BaseCommand
3
3
 
4
4
  def execute(args = [])
5
+ require_object
5
6
 
6
7
  status, response, headers = client.get(EPC::Config::PROJECT_TYPES_PATH + "/#{object_id}")
7
8
 
8
9
  if status.failure?
9
- say("Request failed: [#{response[:message]}]")
10
+ say_err("Request failed: [#{response[:message]}]")
10
11
  else
11
12
  type_table = EPC::TabularOutputter.new([response], [:id, :name, :runtime, :framework, :build_type])
12
13
  say(type_table.print)
@@ -4,6 +4,7 @@ module EPC::Command
4
4
  UPDATABLE_ATTRIBUTES = ["name", "runtime", "framework", "build_type", "build_packaging", "deployable", "runtime_env_types"]
5
5
 
6
6
  def execute(args)
7
+ require_object
7
8
 
8
9
  raise FatalError, "You need to specify at least one attribute to update.\nUpdatable attributes are: [#{UPDATABLE_ATTRIBUTES.join(', ')}]" if args.size < 1
9
10
  params = {}
@@ -29,7 +30,7 @@ module EPC::Command
29
30
  params.each do |attr, val|
30
31
  unless UPDATABLE_ATTRIBUTES.include?(attr)
31
32
  params.delete(attr)
32
- say("Cannot update #{attr}. Updatable attributes are: [#{UPDATABLE_ATTRIBUTES.join(', ')}]")
33
+ say_err("Cannot update #{attr}. Updatable attributes are: [#{UPDATABLE_ATTRIBUTES.join(', ')}]")
33
34
  next
34
35
  end
35
36
  end
@@ -39,7 +40,7 @@ module EPC::Command
39
40
  status, response, headers = client.get(EPC::Config::PROJECT_TYPES_PATH + "/#{object_id}")
40
41
 
41
42
  unless status.successful?
42
- say("Request failed: [#{response[:message]}]")
43
+ say_err("Request failed: [#{response[:message]}]")
43
44
  return 1
44
45
  end
45
46
 
@@ -50,7 +51,7 @@ module EPC::Command
50
51
  if status.successful?
51
52
  say("Project type updated")
52
53
  else
53
- say("Request failed: [#{response[:message]}]")
54
+ say_err("Request failed: [#{response[:message]}]")
54
55
  end
55
56
 
56
57
  return status
@@ -65,10 +65,12 @@ module EPC::Command
65
65
  refresh_command.options[:prompt_refresh] = false if first_time_pull
66
66
  refresh_command.execute(path)
67
67
  return 0
68
+ else
69
+ say_err("\nCould not retrieve URL")
68
70
  end
69
71
  end
70
72
  rescue Exception => ex
71
- say("Pull failed [#{ex.to_s}].")
73
+ say_err("Pull failed [#{ex.to_s}].")
72
74
  end
73
75
  return 1
74
76
  end
@@ -92,7 +94,7 @@ module EPC::Command
92
94
  say("Successfully confirmed the pull with [#{target_url}]")
93
95
  true
94
96
  else
95
- say("Pull confirmation failed [#{response[:message]}].")
97
+ say_err("Pull confirmation failed [#{response[:message]}].")
96
98
  false
97
99
  end
98
100
  end
@@ -100,14 +102,14 @@ module EPC::Command
100
102
  def prep_solution_directory(path, solution_name)
101
103
  solution_id = get_resource_id(EPC::Config::SOLUTIONS_PATH, :name, solution_name)
102
104
  if solution_id.nil?
103
- say("Solution not found")
105
+ say_err("Solution not found")
104
106
  return false
105
107
  end
106
108
 
107
109
  begin
108
110
  Dir.mkdir(File.join(path, solution_name))
109
111
  rescue Exception => ex
110
- say(ex.to_s)
112
+ say_err(ex.to_s)
111
113
  return false
112
114
  end
113
115
 
@@ -116,7 +118,7 @@ module EPC::Command
116
118
  f.write({:id => solution_id, :name => solution_name}.to_json)
117
119
  end
118
120
  rescue Exception => ex
119
- say(ex.to_s)
121
+ say_err(ex.to_s)
120
122
  return false
121
123
  end
122
124
  return true
@@ -145,14 +147,14 @@ module EPC::Command
145
147
  count += 1
146
148
  break
147
149
  else
148
- say("Poller failed to get the pull URL. Aborting.")
150
+ say_err("Poller failed to get the pull URL. Aborting.")
149
151
  failed = true
150
152
  break
151
153
  end
152
154
  end
153
155
 
154
156
  if count > GIVEUP_TICKS
155
- say("\nServer is taking too long to update the pull URL. Please contact the AgileMethods support team.")
157
+ say_err("\nServer is taking too long to update the pull URL. Please contact the AgileMethods support team.")
156
158
  end
157
159
  [false, nil, nil]
158
160
  end
@@ -163,12 +165,12 @@ module EPC::Command
163
165
 
164
166
  def check_pull_directory(path)
165
167
  unless File.exists?(path)
166
- say("Pull path does not exist")
168
+ say_err("Pull path does not exist")
167
169
  return false
168
170
  end
169
171
 
170
172
  unless File.directory?(path)
171
- say("Pull path is not a directory")
173
+ say_err("Pull path is not a directory")
172
174
  return false
173
175
  end
174
176
  return true
@@ -183,7 +185,7 @@ module EPC::Command
183
185
  open(zip_path, "wb") { |io| io.write(response) }
184
186
  [true, zip_path]
185
187
  else
186
- say("Failed to pull the zip file from the build repository [status = #{status}]. Aborting pull command.")
188
+ say_err("Failed to pull the zip file from the build repository [status = #{status}]. Aborting pull command.")
187
189
  [false, nil]
188
190
  end
189
191
  end
@@ -11,10 +11,16 @@ module EPC::Command
11
11
  ZIP_FILE_EXCLUDES = %w(pom.xml)
12
12
  ZIP_EXT_EXCLUDES = ['.class', '.jar']
13
13
 
14
- def execute(project_name = nil)
14
+ def execute(*args)
15
15
  path = "."
16
16
  path = File.expand_path(path)
17
17
 
18
+ @klass_name = "push"
19
+ params = resolve_context(args,
20
+ :accept_no_object => true,
21
+ :skip_object_resolution => Proc.new{|type, id| true},
22
+ :skip_target_resolution => Proc.new{|type, id| true})
23
+
18
24
 
19
25
  if @options[:no_poll].present? && @options[:timeout].present?
20
26
  raise InputError, "You cannot specify both --nopoll and --timeout options at the same time"
@@ -23,45 +29,55 @@ module EPC::Command
23
29
  @timeout = GIVEUP_TICKS
24
30
  parse_timeout_value
25
31
 
26
- solution_id, solution_name = infer_solution_context(nil, path)
32
+ if has_object? && has_target?
33
+ raise InputError, "When manually specifying solution and project context you must provide the path to the file with --direct-deploy" if @options[:direct_deploy].blank?
34
+ solution_name = object_id
35
+ project_name = target_id
36
+ paths = [@options[:direct_deploy]]
37
+ end
38
+
27
39
 
28
- raise FatalError, "Solution could not be inferred" if solution_id.nil?
40
+ if solution_name.blank? && project_name.blank?
41
+ solution_id, solution_name = infer_solution_context(nil, path)
42
+ raise FatalError, "Solution could not be inferred" if solution_id.nil?
29
43
 
30
- if EPC::Config.is_solution_dir?(path)
31
- if project_name.nil?
32
- proceed = ask_yn("You are pushing the [#{solution_name}] solution. Correct: [Yn]? ")
33
- paths = Dir.glob(path +"/*/").select{|dir| EPC::Config.is_project_dir?(dir)}
44
+ if EPC::Config.is_solution_dir?(path)
45
+ if project_name.nil?
46
+ proceed = ask_yn("You are pushing the [#{solution_name}] solution. Correct: [Yn]? ")
47
+ paths = Dir.glob(path +"/*/").select{|dir| EPC::Config.is_project_dir?(dir)}
48
+ else
49
+ project_id, p_name = infer_project_context(project_name, path, solution_id, {:get_project_name => true})
50
+ raise FatalError, "Project not found. Please run this command with the correct project name." if !project_name.nil? && (p_name.nil? || p_name.empty?)
51
+ proceed = ask_yn("You are pushing the [#{p_name}] project belonging to the [#{solution_name}] solution. Correct: [Yn]? ")
52
+ paths = [path + "/#{project_name}"]
53
+ end
54
+ elsif EPC::Config.is_project_dir?(path)
55
+ project_id, project_name = infer_project_context(p_name, path, solution_id, false)
56
+ raise FatalError if project_id.nil?
57
+ proceed = ask_yn("You are pushing the [#{project_name}] project belonging to the [#{solution_name}] solution. Correct: [Yn]? ")
58
+ paths = [path]
34
59
  else
35
- project_id, p_name = infer_project_context(project_name, path, solution_id, {:get_project_name => true})
36
- raise FatalError, "Project not found. Please run this command with the correct project name." if !project_name.nil? && (p_name.nil? || p_name.empty?)
37
- proceed = ask_yn("You are pushing the [#{p_name}] project belonging to the [#{solution_name}] solution. Correct: [Yn]? ")
38
- paths = [path + "/#{project_name}"]
60
+ say("This command must be run from a solution/project directory")
61
+ return 1
39
62
  end
40
- elsif EPC::Config.is_project_dir?(path)
41
- project_id, project_name = infer_project_context(p_name, path, solution_id, false)
42
- raise FatalError if project_id.nil?
43
- proceed = ask_yn("You are pushing the [#{project_name}] project belonging to the [#{solution_name}] solution. Correct: [Yn]? ")
44
- paths = [path]
45
- else
46
- say("This command must be run from a solution/project directory")
47
- return 1
48
- end
49
63
 
50
- if (proceed.upcase == "N" rescue true )
51
- return 1
52
- end
64
+ if (proceed.upcase == "N" rescue true )
65
+ return 1
66
+ end
53
67
 
54
- raise FatalError, "Nothing to push" if paths.empty?
68
+ raise FatalError, "Nothing to push" if paths.empty?
69
+ end
55
70
 
56
71
  @versions = []
57
72
  paths.each do |path|
58
- project_id, project_name = infer_project_context(nil, path, solution_id, {:get_project_name => true})
73
+ project_id, project_name = infer_project_context(nil, path, solution_id, {:get_project_name => true}) unless project_name.present? && has_target?
59
74
  say("\nPushing #{project_name}...")
60
75
  begin
61
76
  zip_path = @options[:direct_deploy].present? ? @options[:direct_deploy] : zip_source(path)
62
77
  raise FatalError, "File missing: #{zip_path}" unless zip_path && File.exists?(zip_path)
63
78
  sha1 = sha1(zip_path)
64
- status, url, signature, id = create_push(project_name, solution_name, sha1, @options[:note], @options[:direct_deploy])
79
+ zip_file_name = @options[:direct_deploy].present? ? File.basename(zip_path) : nil
80
+ status, url, signature, id = create_push(project_name, solution_name, sha1, @options[:note], zip_file_name)
65
81
  if status.successful?
66
82
  pushed = push_zip(zip_path, url, signature, @options[:direct_deploy])
67
83
  resp = confirm_push(id)
@@ -105,7 +121,7 @@ module EPC::Command
105
121
  say("Successfully confirmed the push with [#{target_url}]")
106
122
  response
107
123
  else
108
- say("Push confirmation failed [#{response[:message]}].")
124
+ say_err("Push confirmation failed [#{response[:message]}].")
109
125
  nil
110
126
  end
111
127
  end
@@ -175,12 +191,12 @@ module EPC::Command
175
191
  def check_push_directory(path)
176
192
  project_type = EPC::Config.get_project_value(path, "project_type")["name"] rescue ""
177
193
  unless File.exists?(path)
178
- say("#{path} does not exist")
194
+ say_err("#{path} does not exist")
179
195
  return false
180
196
  end
181
197
 
182
198
  unless File.directory?(path)
183
- say("#{path} is not a directory")
199
+ say_err("#{path} is not a directory")
184
200
  return false
185
201
  end
186
202
 
@@ -18,7 +18,7 @@ module EPC::Command
18
18
  if status.successful?
19
19
  say("Role [#{role}] created")
20
20
  else
21
- say("Request failed: [#{response[:message]}]")
21
+ say_err("Request failed: [#{response[:message]}]")
22
22
  end
23
23
  return status, response[:id]
24
24
  end
@@ -2,6 +2,7 @@ module EPC::Command
2
2
  class DeleteRoleCommand < DeleteCommand
3
3
 
4
4
  def execute(args = [])
5
+ require_object
5
6
 
6
7
  proceed = ask_yn("Are you sure you want to delete the [#{object_id}] role? [Yn] ")
7
8
  if proceed.upcase == "N"
@@ -13,7 +14,7 @@ module EPC::Command
13
14
  if status.successful?
14
15
  say("Role deleted")
15
16
  else
16
- say("Request failed: [#{response[:message]}]")
17
+ say_err("Request failed: [#{response[:message]}]")
17
18
  end
18
19
 
19
20
  return status
@@ -3,10 +3,7 @@ module EPC::Command
3
3
  def execute(args = [])
4
4
 
5
5
  if has_target?
6
- if target_type.downcase != "user"
7
- say("Target type must be User")
8
- return 1
9
- end
6
+ raise InputError, "Target type must be User" if target_type.downcase != "user"
10
7
 
11
8
  status, response, headers = client.get(EPC::Config::USERS_PATH + "/#{target_id}?include=roles")
12
9
  response = response[:roles]
@@ -22,7 +19,7 @@ module EPC::Command
22
19
  say(roles_table.print)
23
20
  end
24
21
  else
25
- say("Request failed: [#{response[:message]}]")
22
+ say_err("Request failed: [#{response[:message]}]")
26
23
  end
27
24
 
28
25
  return status
@@ -2,16 +2,16 @@ module EPC::Command
2
2
  class ShowRoleCommand < ShowCommand
3
3
 
4
4
  def execute(args = [])
5
+ require_object
5
6
  @showable_translations = {
6
7
  :groups => :user_groups
7
8
  }
8
-
9
9
  @showables = args.map(&:to_sym) rescue []
10
10
 
11
11
  status, response, headers = client.get(EPC::Config::ROLES_PATH + "/#{object_id}?include=users,user_groups,grants")
12
12
 
13
13
  unless status.successful?
14
- say("Request failed: [#{response[:message]}]")
14
+ say_err("Request failed: [#{response[:message]}]")
15
15
  return 1
16
16
  end
17
17
 
@@ -4,6 +4,7 @@ module EPC::Command
4
4
  required_options :add_user, :remove_user, :add_group, :remove_group, :add_grant, :remove_grant, :file, :mode => :any?, :message => "You must specify a user/group/grant to added or removed"
5
5
 
6
6
  def execute(args = [])
7
+ require_object
7
8
  role_id = object_id
8
9
 
9
10
  if @options[:file].present?
@@ -32,7 +33,6 @@ module EPC::Command
32
33
  status = add_grant(role_id, @options[:add_grant])
33
34
  end
34
35
 
35
-
36
36
  if @options[:remove_grant].present?
37
37
  status = remove_grant(role_id, @options[:remove_grant])
38
38
  end