jirify 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87e58aae2db7bb11cc05a630d499fb8a5c8106334d53e53aa5d1a6abdf6bc998
4
- data.tar.gz: 1bd3b4c51f15571fd293ad0600b2b02908367d888c1e11c5ab932bc311da3472
3
+ metadata.gz: 30fe694d532ff7f42489b0e15e9c5e3baf4f3ec00f82b14a2132621bd6132bd0
4
+ data.tar.gz: a01941f15a19def128da94ea49d05fd9aeace88b283c0a0c4be108ebb54874bf
5
5
  SHA512:
6
- metadata.gz: b5510799bfe2bf446aad40b7d39db2b6c5db578b7b9d11a44dacf45436215e487114457fab50c213a6d9a3a9a72c0b35461774a659d51a96df0c258e3900c693
7
- data.tar.gz: a91184d1f9725aef850a11d87c342236d2d7f1ae609a0ca472b98b94464ed2a38178098f492376951343611f7490a592148d2f7df865aa32ce4fceddff01f91b
6
+ metadata.gz: 4bcd7b93913fdf79bec9914d42d280c0aae9f1a237e1d7eb47d75b153181d0b26af7b61c05094d816ffd7cbcbf6090c51c45277146b874e25c69faa1a411e10a
7
+ data.tar.gz: 17b11d2fff2083801a49149c615264261825bba23255cdce8ee2fcc9ce01b630a30644b0936e126be549414e65fbd1e4eece9b1d262e2f8921567aed1ca9caad
data/README.md CHANGED
@@ -3,7 +3,7 @@ A simple ruby gem that helps me work with jira
3
3
 
4
4
  # How to use
5
5
  1. Run `gem install jirify`.
6
- 1. Execute `jira setup` and go through the setup process OR if you had the previous `config.yml` file you can just do `mv config.yml ~/.jirify`
6
+ 1. Execute `jira setup` and go through the setup process OR if you had the previous `config.yml` or `.jirify` file you can just move it to the `~/.jirify/` folder.
7
7
  1. Execute `jira` and `jira <command> help` to learn about available commands.
8
8
 
9
9
  # To Do
@@ -0,0 +1,110 @@
1
+ #//bin/bash
2
+ # jirify tab-completion script for bash.
3
+
4
+ JIRIFY_FOLDER="${HOME}/.jirify"
5
+ ISSUE_KEYS_CACHE="${JIRIFY_FOLDER}/.cache"
6
+ CACHE_TTL=60
7
+
8
+ _jirify_write_issues_to_cache() {
9
+ my_issue_keys="$(jira issues -k)"
10
+ echo "$my_issue_keys" > "$ISSUE_KEYS_CACHE"
11
+ }
12
+
13
+ _jirify_maybe_reload_cache() {
14
+ if [ -f $ISSUE_KEYS_CACHE ]; then
15
+ time_elapsed=`expr $(date +%s) - $(stat -f %c $ISSUE_KEYS_CACHE)`
16
+
17
+ if (( time_elapsed >= CACHE_TTL )); then
18
+ _jirify_write_issues_to_cache
19
+ fi
20
+ else
21
+ _jirify_write_issues_to_cache
22
+ fi
23
+ }
24
+
25
+ _jirify_completions() {
26
+ current="${COMP_WORDS[COMP_CWORD]}"
27
+ previous="${COMP_WORDS[COMP_CWORD-1]}"
28
+
29
+ top_level_commands="help issues projects setup sprint version"
30
+ projects_commands="help list"
31
+ setup_commands="help init verbose"
32
+ issues_commands="help assignee block close mine open review start status take todo transition transitions unassign unblock"
33
+
34
+ _compgen_issue_keys() {
35
+ _jirify_maybe_reload_cache
36
+ my_issue_keys=$(<${ISSUE_KEYS_CACHE})
37
+ COMPREPLY=($(compgen -W "${my_issue_keys}" -- ${current}))
38
+ }
39
+
40
+ _compgen_top_level() {
41
+ COMPREPLY=($(compgen -W "${top_level_commands}" -- ${current}))
42
+ }
43
+
44
+ _compgen_projects() {
45
+ COMPREPLY=($(compgen -W "${projects_commands}" -- ${current}))
46
+ }
47
+
48
+ _compgen_setup() {
49
+ COMPREPLY=($(compgen -W "${setup_commands}" -- ${current}))
50
+ }
51
+
52
+ _compgen_issues() {
53
+ COMPREPLY=($(compgen -W "${issues_commands}" -- ${current}))
54
+ }
55
+
56
+ if [ $COMP_CWORD == 1 ]
57
+ then
58
+ _compgen_top_level
59
+ return 0
60
+ fi
61
+
62
+ if [ $COMP_CWORD == 2 ]
63
+ then
64
+ case "$previous" in
65
+ "help")
66
+ _compgen_top_level
67
+ return 0
68
+ ;;
69
+ "projects")
70
+ _compgen_projects
71
+ return 0
72
+ ;;
73
+ "setup")
74
+ _compgen_setup
75
+ return 0
76
+ ;;
77
+ i|issues)
78
+ _compgen_issues
79
+ return 0
80
+ ;;
81
+ esac
82
+ fi
83
+
84
+ if [ $COMP_CWORD == 3 ]
85
+ then
86
+ action="${COMP_WORDS[COMP_CWORD-2]}"
87
+
88
+ if [ "$previous" == "help" ]; then
89
+ case "$action" in
90
+ "projects")
91
+ _compgen_projects
92
+ return 0
93
+ ;;
94
+ "setup")
95
+ _compgen_setup
96
+ return 0
97
+ ;;
98
+ i|issues)
99
+ _compgen_issues
100
+ return 0
101
+ ;;
102
+ esac
103
+ elif [ "$action" == "issues" ] || [ "$action" == "i" ]; then
104
+ _compgen_issue_keys
105
+ return 0
106
+ fi
107
+ fi
108
+ }
109
+
110
+ complete -F _jirify_completions jira
@@ -6,6 +6,7 @@ module Jirify
6
6
  default_task :mine
7
7
 
8
8
  desc 'mine', 'List all of the issues assigned to you in the current sprint'
9
+ method_option :key_only, type: :boolean, aliases: '-k', desc: 'Show only issue keys'
9
10
  method_option :in_progress, type: :boolean, aliases: '-i', desc: 'Show only issues in progress'
10
11
  method_option :in_review, type: :boolean, aliases: '-r', desc: 'Show only issues in review'
11
12
  method_option :closed, type: :boolean, aliases: '-c', desc: 'Show only closed issues'
@@ -27,7 +28,13 @@ module Jirify
27
28
  def mine
28
29
  statuses = build_issue_statuses(options)
29
30
  issues = Jirify::Issue.list_mine(statuses, options[:all])
30
- issues.each { |issue| issue.print Config.always_verbose || options[:verbose] }
31
+ issues.each do |issue|
32
+ if options[:key_only]
33
+ puts issue.key
34
+ else
35
+ issue.print Config.always_verbose || options[:verbose]
36
+ end
37
+ end
31
38
  end
32
39
 
33
40
  desc 'open [ISSUE]', 'Opens an issue in your browser'
@@ -32,12 +32,15 @@ module Jirify
32
32
  options['options']['filter_by_labels'] = labels unless labels.empty?
33
33
 
34
34
  Config.write(options)
35
+
36
+ say "Done!"
37
+ say "If you want to enable bash completion, source #{Config.config_folder}/jirify.bash_completion.sh"
35
38
  end
36
39
 
37
40
  desc 'verbose', 'Set always verbose to true or false'
38
- method_option :enable, type: :boolean, aliases: '-e', default: false, desc: 'Enable or disable'
41
+ method_option :enable, type: :boolean, aliases: '-e', default: false, desc: 'Enable or Disable'
39
42
  def verbose
40
- Config.verbose(options[:enable])
43
+ Config.verbose = options[:enable]
41
44
  end
42
45
  end
43
46
  end
data/lib/jirify/config.rb CHANGED
@@ -1,10 +1,30 @@
1
1
  require 'yaml'
2
+ require 'fileutils'
2
3
 
3
4
  module Jirify
4
5
  class Config
5
6
  class << self
7
+ CONFIG_FOLDER = "#{Dir.home}/.jirify".freeze
8
+ CONFIG_FILE = "#{CONFIG_FOLDER}/.jirify".freeze
9
+
10
+ def config_folder
11
+ initialize! unless initialized?
12
+ @config_folder ||= CONFIG_FOLDER
13
+ end
14
+
15
+ def config_file
16
+ initialize! unless initialized?
17
+ @config_file ||= CONFIG_FILE
18
+ end
19
+
6
20
  def initialized?
7
- File.exist? config_file
21
+ File.directory?(CONFIG_FOLDER) && File.exist?(CONFIG_FILE)
22
+ end
23
+
24
+ def initialize!
25
+ FileUtils::mkdir_p CONFIG_FOLDER
26
+ FileUtils::touch CONFIG_FILE
27
+ FileUtils::cp "#{File.expand_path('..', File.dirname(__dir__))}/jirify.bash_completion.sh", CONFIG_FOLDER
8
28
  end
9
29
 
10
30
  def write(config)
@@ -14,7 +34,7 @@ module Jirify
14
34
  File.write(config_file, config.to_yaml)
15
35
  end
16
36
 
17
- def verbose(value)
37
+ def verbose=(value)
18
38
  unless initialized?
19
39
  puts 'ERROR: You must initialize Jirify first!'.red
20
40
  exit(0)
@@ -25,10 +45,6 @@ module Jirify
25
45
  write(config)
26
46
  end
27
47
 
28
- def config_file
29
- @config_file ||= "#{Dir.home}/.jirify"
30
- end
31
-
32
48
  def options
33
49
  unless initialized?
34
50
  puts 'ERROR: You must initialize Jirify first!'.red
@@ -55,17 +71,23 @@ module Jirify
55
71
  end
56
72
 
57
73
  def statuses
58
- options['statuses'] || {
74
+ default = {
59
75
  'blocked' => 'Blocked',
60
76
  'todo' => 'To Do',
61
77
  'in_progress' => 'In Progress',
62
78
  'in_review' => 'In Review',
63
79
  'done' => 'Closed'
64
80
  }
81
+
82
+ if initialized?
83
+ options['statuses'] || default
84
+ else
85
+ default
86
+ end
65
87
  end
66
88
 
67
89
  def transitions
68
- options['transitions'] || {
90
+ default = {
69
91
  'block' => 'Blocked',
70
92
  'unblock' => 'Unblock',
71
93
  'start' => 'Start Progress',
@@ -75,6 +97,12 @@ module Jirify
75
97
  'close' => 'Close',
76
98
  'reopen' => 'Reopen'
77
99
  }
100
+
101
+ if initialized?
102
+ options['transitions'] || default
103
+ else
104
+ default
105
+ end
78
106
  end
79
107
 
80
108
  def client_options
@@ -1,3 +1,3 @@
1
1
  module Jirify
2
- VERSION = '0.1.5'.freeze
2
+ VERSION = '0.1.6'.freeze
3
3
  end
data/lib/jirify.rb CHANGED
@@ -27,16 +27,16 @@ module Jirify
27
27
  puts "Current Jirify version: #{VERSION}"
28
28
  end
29
29
 
30
- desc 'setup SUBCOMMAND', 'Jirify setup tools'
30
+ desc 'setup [SUBCOMMAND]', 'Jirify setup tools'
31
31
  subcommand 'setup', Subcommands::Setup
32
32
 
33
- desc 'i SUBCOMMAND', 'Alias for <jira issues>'
33
+ desc 'i [SUBCOMMAND]', 'Alias for <jira issues>'
34
34
  subcommand 'i', Subcommands::Issues
35
35
 
36
- desc 'issues SUBCOMMAND', 'Work with JIRA Issues'
36
+ desc 'issues [SUBCOMMAND]', 'Work with JIRA Issues'
37
37
  subcommand 'issues', Subcommands::Issues
38
38
 
39
- desc 'projects SUBCOMMAND', 'Work with JIRA Projects'
39
+ desc 'projects [SUBCOMMAND]', 'Work with JIRA Projects'
40
40
  subcommand 'projects', Subcommands::Projects
41
41
  end
42
42
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jirify
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Georgi Gardev
@@ -89,6 +89,7 @@ extra_rdoc_files: []
89
89
  files:
90
90
  - README.md
91
91
  - bin/jira
92
+ - jirify.bash_completion.sh
92
93
  - lib/jirify.rb
93
94
  - lib/jirify/cli/issue.rb
94
95
  - lib/jirify/cli/project.rb