jira_cli 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +841 -10
- data/jira_cli.gemspec +1 -1
- data/lib/jira_cli/version.rb +1 -1
- data/lib/jira_cli/wrapper.rb +46 -38
- data/lib/jira_cli.rb +15 -0
- metadata +2 -2
data/jira_cli.gemspec
CHANGED
@@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0").reject do |f|
|
17
|
-
f.match(%r{^(test|spec|features)/}) || ['build_examples.rb', 'debug.rb', 'examples.yml'].include?(f)
|
17
|
+
f.match(%r{^(test|spec|features)/}) || ['build_examples.rb', 'debug.rb', 'document_examples.rb', 'examples.yml'].include?(f)
|
18
18
|
end
|
19
19
|
|
20
20
|
spec.bindir = 'exe'
|
data/lib/jira_cli/version.rb
CHANGED
data/lib/jira_cli/wrapper.rb
CHANGED
@@ -2,54 +2,61 @@ module JiraCli
|
|
2
2
|
class Wrapper
|
3
3
|
include Singleton
|
4
4
|
|
5
|
-
|
5
|
+
CLI_METHODS = [:add_attachment, :add_attachments, :add_comment, :add_component, :add_custom_field, :add_group, :add_labels, :add_project_category, :add_project_role, :add_project_role_actors, :add_remote_link, :add_transition, :add_transition_function, :add_user, :add_user_to_group, :add_user_to_group_with_file, :add_user_with_file, :add_version, :add_vote, :add_watchers, :add_work, :archive_version, :assign_issue, :associate_workflow, :clone_issue, :clone_issues, :clone_project, :copy_attachments, :copy_component, :copy_components, :copy_field_value, :copy_project_role_actors, :copy_version, :copy_versions, :copy_workflow, :create_board, :create_filter, :create_issue, :create_or_update_issue, :create_project, :create_workflow_scheme, :delete_board, :delete_component, :delete_field_configuration, :delete_field_configuration_scheme, :delete_filter, :delete_issue, :delete_issue_security_scheme, :delete_issue_type_scheme, :delete_issue_type_screen_scheme, :delete_link, :delete_notification_scheme, :delete_permission_scheme, :delete_project, :delete_screen, :delete_screen_scheme, :delete_version, :delete_workflow, :delete_workflow_scheme, :export_data, :export_site, :export_workflow, :get_application_link_list, :get_attachment, :get_attachment_list, :get_available_steps, :get_board_list, :get_client_info, :get_comment, :get_comment_list, :get_comments, :get_component, :get_component_list, :get_custom_field_list, :get_field_configuration_list, :get_field_configuration_scheme_list, :get_field_list, :get_field_value, :get_filter, :get_filter_list, :get_group_list, :get_issue, :get_issue_history_list, :get_issue_list, :get_issue_security_scheme_list, :get_issue_type_list, :get_issue_type_scheme_list, :get_issue_type_screen_scheme_list, :get_link_list, :get_link_type_list, :get_login_info, :get_notification_scheme_list, :get_permission_scheme_list, :get_project, :get_project_category, :get_project_category_list, :get_project_list, :get_project_role_actor_list, :get_project_role_by_user_list, :get_project_role_list, :get_remote_link_list, :get_screen_list, :get_screen_scheme_list, :get_security_level_list, :get_server_info, :get_status_list, :get_transition_list, :get_user, :get_user_list, :get_version, :get_version_list, :get_voter_list, :get_watcher_list, :get_workflow, :get_workflow_list, :get_workflow_scheme, :get_workflow_scheme_list, :get_work_list, :import, :import_workflow, :link_issue, :login, :logout, :modify_field_value, :progress_issue, :release_version, :remove_attachment, :remove_comment, :remove_custom_field, :remove_group, :remove_labels, :remove_project_category, :remove_project_role, :remove_project_role_actors, :remove_remote_link, :remove_user, :remove_user_from_group, :remove_user_from_group_with_file, :remove_user_property, :remove_user_with_file, :remove_vote, :remove_watchers, :remove_work, :render_request, :restore_export, :run, :run_from_attachment_list, :run_from_comment_list, :run_from_component_list, :run_from_csv, :run_from_field_configuration_list, :run_from_field_configuration_scheme_list, :run_from_group_list, :run_from_issue_list, :run_from_issue_security_scheme_list, :run_from_issue_type_scheme_list, :run_from_issue_type_screen_scheme_list, :run_from_link_list, :run_from_list, :run_from_notification_scheme_list, :run_from_permission_scheme_list, :run_from_project_category_list, :run_from_project_list, :run_from_remote_link_list, :run_from_screen_list, :run_from_screen_scheme_list, :run_from_sql, :run_from_user_list, :run_from_version_list, :run_from_workflow_list, :run_from_workflow_scheme_list, :set_field_value, :set_share_scope, :transition_issue, :unarchive_version, :unrelease_version, :update_comment, :update_component, :update_filter, :update_issue, :update_project, :update_project_category, :update_project_role, :update_user, :update_user_property, :update_version, :update_work, :validate_license]
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
CSV_RESPONSE_METHODS = {
|
8
|
+
get_attachment_list: {label: 'attachments', id_col: :id},
|
9
|
+
get_comment_list: {label: 'comments', id_col: :id},
|
10
|
+
get_component_list: {label: 'components', id_col: :id},
|
11
|
+
get_issue_list: {label: 'issues', id_col: :id},
|
12
|
+
get_issue_type_list: {label: 'issue types', id_col: :id},
|
13
|
+
get_issue_type_screen_scheme_list: {label: 'issue type screen schemes', id_col: :id},
|
14
|
+
get_issue_type_scheme_list: {label: 'issue type schemes', id_col: :id},
|
15
|
+
get_link_list: {label: 'links', id_col: :link_id},
|
16
|
+
get_screen_list: {label: 'screens', id_col: :id},
|
17
|
+
get_screen_scheme_list: {label: 'screen schemes', id_col: :id},
|
18
|
+
get_version_list: {label: 'versions', id_col: :id},
|
19
|
+
get_workflow_list: {label: 'workflows', id_col: :name},
|
20
|
+
get_workflow_scheme_list: {label: 'workflow schemes', id_col: :id}
|
21
|
+
}
|
10
22
|
|
11
23
|
def initialize
|
12
|
-
|
13
|
-
|
14
|
-
define_singleton_method s_method, -> **jira_args {jira_cmd s_method.to_s.camelize(:lower), **jira_args}
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
def override_csv_methods
|
19
|
-
{
|
20
|
-
get_attachment_list: {label: 'attachments', id_col: :id},
|
21
|
-
get_comment_list: {label: 'comments', id_col: :id},
|
22
|
-
get_component_list: {label: 'components', id_col: :id},
|
23
|
-
get_issue_list: {label: 'issues', id_col: :id},
|
24
|
-
get_issue_type_list: {label: 'issue types', id_col: :id},
|
25
|
-
get_issue_type_screen_scheme_list: {label: 'issue type screen schemes', id_col: :id},
|
26
|
-
get_issue_type_scheme_list: {label: 'issue type schemes', id_col: :id},
|
27
|
-
get_link_list: {label: 'links', id_col: :link_id},
|
28
|
-
get_screen_list: {label: 'screens', id_col: :id},
|
29
|
-
get_screen_scheme_list: {label: 'screen schemes', id_col: :id},
|
30
|
-
get_version_list: {label: 'versions', id_col: :id},
|
31
|
-
get_workflow_list: {label: 'workflows', id_col: :name},
|
32
|
-
get_workflow_scheme_list: {label: 'workflow schemes', id_col: :id}
|
33
|
-
}.each do |s_method, csv_args|
|
34
|
-
define_singleton_method s_method, -> **jira_args {get_csv_list **{cmd: s_method.to_s.camelize(:lower)}.merge(**jira_args, **csv_args)}
|
35
|
-
end
|
24
|
+
@jira_cmd = configure_jira_cmd
|
25
|
+
define_cli_methods
|
36
26
|
end
|
37
27
|
|
38
|
-
# TODO: this is being overriden in the constructor
|
39
|
-
# def add_version project:, name:, **jira_args
|
40
|
-
# formatted_args = jira_args.map do |k, v|
|
41
|
-
# v = v.strftime('%-m/%d/%y') if [:start_date, :date].include?(k)
|
42
|
-
# [k, v]
|
43
|
-
# end.to_h
|
44
|
-
# jira_cmd 'addVersion', project: project, name: name, **formatted_args
|
45
|
-
# end
|
46
|
-
|
47
28
|
private
|
48
29
|
|
49
30
|
def check_first_line output, regex
|
50
31
|
raise OutputError.new("Expected response to begin with \"#{regex}\"", output) unless output =~ Regexp.new(regex)
|
51
32
|
end
|
52
33
|
|
34
|
+
def configure_jira_cmd
|
35
|
+
cli_opts = {
|
36
|
+
server: :server_url,
|
37
|
+
user: :user,
|
38
|
+
password: :password
|
39
|
+
}.map do |cli_opt, config_var|
|
40
|
+
JiraCli.send(config_var) ? "--#{cli_opt} \"#{JiraCli.send(config_var)}\"" : nil
|
41
|
+
end.compact
|
42
|
+
|
43
|
+
[JiraCli.cli_jar_path ? "java -jar \"#{JiraCli.cli_jar_path}\"" : 'jira', *cli_opts].join ' '
|
44
|
+
end
|
45
|
+
|
46
|
+
def define_cli_methods
|
47
|
+
CLI_METHODS.each do |s_method|
|
48
|
+
cli_method = s_method.to_s.camelize(:lower)
|
49
|
+
|
50
|
+
define_singleton_method s_method, -> **jira_args do
|
51
|
+
if jira_args.delete(:parse_response) && CSV_RESPONSE_METHODS[s_method]
|
52
|
+
get_csv_list **{cmd: cli_method}.merge(**jira_args, **CSV_RESPONSE_METHODS[s_method])
|
53
|
+
else
|
54
|
+
jira_cmd cli_method, **jira_args
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
53
60
|
def get_csv_list cmd:, label:, id_col:, **jira_args
|
54
61
|
output = jira_cmd cmd, **jira_args
|
55
62
|
check_first_line output, '^\d* '+label
|
@@ -80,7 +87,8 @@ module JiraCli
|
|
80
87
|
cmd
|
81
88
|
end.join(' ')
|
82
89
|
|
83
|
-
stdout, stderr, status = Open3.capture3 "
|
90
|
+
stdout, stderr, status = Open3.capture3 "#{@jira_cmd} #{cmd_args}"
|
91
|
+
|
84
92
|
# ap "jira #{cmd_args}"
|
85
93
|
# puts stdout
|
86
94
|
raise stderr.strip if stderr != ''
|
data/lib/jira_cli.rb
CHANGED
@@ -10,4 +10,19 @@ require 'jira_cli/wrapper'
|
|
10
10
|
require 'jira_cli/output_error'
|
11
11
|
|
12
12
|
module JiraCli
|
13
|
+
mattr_accessor :cli_jar_path
|
14
|
+
@@cli_jar_path = nil
|
15
|
+
|
16
|
+
mattr_accessor :password
|
17
|
+
@@password = nil
|
18
|
+
|
19
|
+
mattr_accessor :server_url
|
20
|
+
@@server_url = nil
|
21
|
+
|
22
|
+
mattr_accessor :user
|
23
|
+
@@user = nil
|
24
|
+
|
25
|
+
def self.setup
|
26
|
+
yield self
|
27
|
+
end
|
13
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jira_cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sean Huber
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|