doing 2.0.18 → 2.0.22

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 (107) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +22 -0
  3. data/Gemfile.lock +15 -5
  4. data/README.md +1 -1
  5. data/bin/doing +2 -18
  6. data/doing.gemspec +5 -4
  7. data/doing.rdoc +2 -2
  8. data/generate_completions.sh +3 -3
  9. data/lib/doing/cli_status.rb +6 -2
  10. data/lib/doing/completion/bash_completion.rb +185 -0
  11. data/lib/doing/completion/fish_completion.rb +175 -0
  12. data/lib/doing/completion/string.rb +17 -0
  13. data/lib/doing/completion/zsh_completion.rb +140 -0
  14. data/lib/doing/completion.rb +39 -0
  15. data/lib/doing/version.rb +1 -1
  16. data/lib/doing/wwid.rb +18 -6
  17. data/lib/doing.rb +1 -1
  18. data/lib/helpers/fzf/.goreleaser.yml +119 -0
  19. data/lib/helpers/fzf/.rubocop.yml +28 -0
  20. data/lib/helpers/fzf/ADVANCED.md +565 -0
  21. data/lib/helpers/fzf/BUILD.md +49 -0
  22. data/lib/helpers/fzf/CHANGELOG.md +1193 -0
  23. data/lib/helpers/fzf/Dockerfile +11 -0
  24. data/lib/helpers/fzf/LICENSE +21 -0
  25. data/lib/helpers/fzf/Makefile +166 -0
  26. data/lib/helpers/fzf/README-VIM.md +486 -0
  27. data/lib/helpers/fzf/README.md +712 -0
  28. data/lib/helpers/fzf/bin/fzf-tmux +233 -0
  29. data/lib/helpers/fzf/doc/fzf.txt +512 -0
  30. data/lib/helpers/fzf/go.mod +17 -0
  31. data/lib/helpers/fzf/go.sum +31 -0
  32. data/lib/helpers/fzf/install +382 -0
  33. data/lib/helpers/fzf/install.ps1 +65 -0
  34. data/lib/helpers/fzf/main.go +14 -0
  35. data/lib/helpers/fzf/man/man1/fzf-tmux.1 +68 -0
  36. data/lib/helpers/fzf/man/man1/fzf.1 +1001 -0
  37. data/lib/helpers/fzf/plugin/fzf.vim +1048 -0
  38. data/lib/helpers/fzf/shell/completion.bash +381 -0
  39. data/lib/helpers/fzf/shell/completion.zsh +329 -0
  40. data/lib/helpers/fzf/shell/key-bindings.bash +96 -0
  41. data/lib/helpers/fzf/shell/key-bindings.fish +172 -0
  42. data/lib/helpers/fzf/shell/key-bindings.zsh +114 -0
  43. data/lib/helpers/fzf/src/LICENSE +21 -0
  44. data/lib/helpers/fzf/src/algo/algo.go +884 -0
  45. data/lib/helpers/fzf/src/algo/algo_test.go +197 -0
  46. data/lib/helpers/fzf/src/algo/normalize.go +492 -0
  47. data/lib/helpers/fzf/src/ansi.go +409 -0
  48. data/lib/helpers/fzf/src/ansi_test.go +427 -0
  49. data/lib/helpers/fzf/src/cache.go +81 -0
  50. data/lib/helpers/fzf/src/cache_test.go +39 -0
  51. data/lib/helpers/fzf/src/chunklist.go +89 -0
  52. data/lib/helpers/fzf/src/chunklist_test.go +80 -0
  53. data/lib/helpers/fzf/src/constants.go +85 -0
  54. data/lib/helpers/fzf/src/core.go +351 -0
  55. data/lib/helpers/fzf/src/history.go +96 -0
  56. data/lib/helpers/fzf/src/history_test.go +68 -0
  57. data/lib/helpers/fzf/src/item.go +44 -0
  58. data/lib/helpers/fzf/src/item_test.go +23 -0
  59. data/lib/helpers/fzf/src/matcher.go +235 -0
  60. data/lib/helpers/fzf/src/merger.go +120 -0
  61. data/lib/helpers/fzf/src/merger_test.go +88 -0
  62. data/lib/helpers/fzf/src/options.go +1691 -0
  63. data/lib/helpers/fzf/src/options_test.go +457 -0
  64. data/lib/helpers/fzf/src/pattern.go +425 -0
  65. data/lib/helpers/fzf/src/pattern_test.go +209 -0
  66. data/lib/helpers/fzf/src/protector/protector.go +8 -0
  67. data/lib/helpers/fzf/src/protector/protector_openbsd.go +10 -0
  68. data/lib/helpers/fzf/src/reader.go +201 -0
  69. data/lib/helpers/fzf/src/reader_test.go +63 -0
  70. data/lib/helpers/fzf/src/result.go +243 -0
  71. data/lib/helpers/fzf/src/result_others.go +16 -0
  72. data/lib/helpers/fzf/src/result_test.go +159 -0
  73. data/lib/helpers/fzf/src/result_x86.go +16 -0
  74. data/lib/helpers/fzf/src/terminal.go +2832 -0
  75. data/lib/helpers/fzf/src/terminal_test.go +638 -0
  76. data/lib/helpers/fzf/src/terminal_unix.go +26 -0
  77. data/lib/helpers/fzf/src/terminal_windows.go +45 -0
  78. data/lib/helpers/fzf/src/tokenizer.go +253 -0
  79. data/lib/helpers/fzf/src/tokenizer_test.go +112 -0
  80. data/lib/helpers/fzf/src/tui/dummy.go +46 -0
  81. data/lib/helpers/fzf/src/tui/light.go +987 -0
  82. data/lib/helpers/fzf/src/tui/light_unix.go +110 -0
  83. data/lib/helpers/fzf/src/tui/light_windows.go +145 -0
  84. data/lib/helpers/fzf/src/tui/tcell.go +721 -0
  85. data/lib/helpers/fzf/src/tui/tcell_test.go +392 -0
  86. data/lib/helpers/fzf/src/tui/ttyname_unix.go +47 -0
  87. data/lib/helpers/fzf/src/tui/ttyname_windows.go +14 -0
  88. data/lib/helpers/fzf/src/tui/tui.go +625 -0
  89. data/lib/helpers/fzf/src/tui/tui_test.go +20 -0
  90. data/lib/helpers/fzf/src/util/atomicbool.go +34 -0
  91. data/lib/helpers/fzf/src/util/atomicbool_test.go +17 -0
  92. data/lib/helpers/fzf/src/util/chars.go +198 -0
  93. data/lib/helpers/fzf/src/util/chars_test.go +46 -0
  94. data/lib/helpers/fzf/src/util/eventbox.go +96 -0
  95. data/lib/helpers/fzf/src/util/eventbox_test.go +61 -0
  96. data/lib/helpers/fzf/src/util/slab.go +12 -0
  97. data/lib/helpers/fzf/src/util/util.go +138 -0
  98. data/lib/helpers/fzf/src/util/util_test.go +40 -0
  99. data/lib/helpers/fzf/src/util/util_unix.go +47 -0
  100. data/lib/helpers/fzf/src/util/util_windows.go +83 -0
  101. data/lib/helpers/fzf/test/fzf.vader +175 -0
  102. data/lib/helpers/fzf/test/test_go.rb +2626 -0
  103. data/lib/helpers/fzf/uninstall +117 -0
  104. data/scripts/generate_bash_completions.rb +6 -12
  105. data/scripts/generate_fish_completions.rb +7 -16
  106. data/scripts/generate_zsh_completions.rb +6 -15
  107. metadata +144 -9
@@ -0,0 +1,140 @@
1
+ module Doing
2
+ module Completion
3
+ class ZshCompletions
4
+
5
+ attr_accessor :commands, :global_options
6
+
7
+ def generate_helpers
8
+ out=<<~EOFUNCTIONS
9
+ compdef _doing doing
10
+
11
+ function _doing() {
12
+ local line state
13
+
14
+ function _commands {
15
+ local -a commands
16
+
17
+ commands=(
18
+ #{generate_subcommand_completions.join("\n ")}
19
+ )
20
+ _describe 'command' commands
21
+ }
22
+
23
+ _arguments -C \
24
+ "1: :_commands" \
25
+ "*::arg:->args"
26
+
27
+
28
+
29
+ case $line[1] in
30
+ #{generate_subcommand_option_completions(indent: ' ').join("\n ")}
31
+ esac
32
+
33
+ _arguments -s $args
34
+ }
35
+
36
+ EOFUNCTIONS
37
+ @bar.finish
38
+ out
39
+ end
40
+
41
+ def get_help_sections(command = '')
42
+ res = `doing help #{command}`.strip
43
+ scanned = res.scan(/(?m-i)^([A-Z ]+)\n([\s\S]*?)(?=\n+[A-Z]+|\Z)/)
44
+ sections = {}
45
+ scanned.each do |sect|
46
+ title = sect[0].downcase.strip.gsub(/ +/, '_').to_sym
47
+ content = sect[1].split(/\n/).map(&:strip).delete_if(&:empty?)
48
+ sections[title] = content
49
+ end
50
+ sections
51
+ end
52
+
53
+ def parse_option(option)
54
+ res = option.match(/(?:-(?<short>\w), )?(?:--(?:\[no-\])?(?<long>[\w_]+)(?:=(?<arg>\w+))?)\s+- (?<desc>.*?)$/)
55
+ return nil unless res
56
+
57
+ {
58
+ short: res['short'],
59
+ long: res['long'],
60
+ arg: res[:arg],
61
+ description: res['desc'].short_desc
62
+ }
63
+ end
64
+
65
+ def parse_options(options)
66
+ options.map { |opt| parse_option(opt) }
67
+ end
68
+
69
+ def parse_command(command)
70
+ res = command.match(/^(?<cmd>[^, \t]+)(?<alias>(?:, [^, \t]+)*)?\s+- (?<desc>.*?)$/)
71
+ commands = [res['cmd']]
72
+ commands.concat(res['alias'].split(/, /).delete_if(&:empty?)) if res['alias']
73
+
74
+ {
75
+ commands: commands,
76
+ description: res['desc'].short_desc
77
+ }
78
+ end
79
+
80
+ def parse_commands(commands)
81
+ commands.map { |cmd| parse_command(cmd) }
82
+ end
83
+
84
+ def generate_subcommand_completions
85
+ out = []
86
+ @commands.each_with_index do |cmd, i|
87
+ cmd[:commands].each do |c|
88
+ out << "'#{c}:#{cmd[:description].gsub(/'/, '\\\'')}'"
89
+ end
90
+ end
91
+ out
92
+ end
93
+
94
+ def generate_subcommand_option_completions(indent: ' ')
95
+
96
+ out = []
97
+
98
+ @commands.each_with_index do |cmd, i|
99
+ @bar.advance
100
+
101
+ data = get_help_sections(cmd[:commands].first)
102
+ option_arr = []
103
+
104
+ if data[:command_options]
105
+ parse_options(data[:command_options]).each do |option|
106
+ next if option.nil?
107
+
108
+ arg = option[:arg] ? '=' : ''
109
+
110
+ option_arr << if option[:short]
111
+ %({-#{option[:short]},--#{option[:long]}#{arg}}"[#{option[:description].gsub(/'/, '\\\'')}]")
112
+ else
113
+ %("(--#{option[:long]}#{arg})--#{option[:long]}#{arg}}[#{option[:description].gsub(/'/, '\\\'')}]")
114
+ end
115
+ end
116
+ end
117
+
118
+ cmd[:commands].each do |c|
119
+ out << "#{c}) \n#{indent} args=( #{option_arr.join(' ')} )\n#{indent};;"
120
+ end
121
+ end
122
+
123
+ out
124
+ end
125
+
126
+ def initialize
127
+ data = get_help_sections
128
+ @global_options = parse_options(data[:global_options])
129
+ @commands = parse_commands(data[:commands])
130
+ @bar = TTY::ProgressBar.new(" \033[0;0;33mGenerating Zsh completions: \033[0;35;40m[:bar]\033[0m", total: @commands.count, bar_format: :blade)
131
+ @bar.resize(25)
132
+ end
133
+
134
+ def generate_completions
135
+ @bar.start
136
+ generate_helpers
137
+ end
138
+ end
139
+ end
140
+ end
@@ -0,0 +1,39 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'tty-progressbar'
4
+
5
+ $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), 'completion'))
6
+ require 'string'
7
+ require 'fish_completion'
8
+ require 'zsh_completion'
9
+ require 'bash_completion'
10
+
11
+ module Doing
12
+ # Completion script generator
13
+ module Completion
14
+ class << self
15
+ def generate_completion(type: 'zsh', file: 'stdout')
16
+
17
+ generator = case type.to_s
18
+ when /^f/
19
+ FishCompletions.new
20
+ when /^b/
21
+ BashCompletions.new
22
+ else
23
+ ZshCompletions.new
24
+ end
25
+
26
+ result = generator.generate_completions
27
+
28
+ if file =~ /^stdout$/i
29
+ $stdout.puts result
30
+ else
31
+ File.open(File.expand_path(file), 'w') do |f|
32
+ f.puts result
33
+ end
34
+ Doing.logger.warn('File written:', "#{type} completions written to #{file}")
35
+ end
36
+ end
37
+ end
38
+ end
39
+ end
data/lib/doing/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Doing
2
- VERSION = '2.0.18'
2
+ VERSION = '2.0.22'
3
3
  end
data/lib/doing/wwid.rb CHANGED
@@ -611,6 +611,22 @@ module Doing
611
611
  last_entry
612
612
  end
613
613
 
614
+ def fzf
615
+ fzf_dir = File.join(File.dirname(__FILE__), '../helpers/fzf')
616
+ FileUtils.mkdir_p(fzf_dir) unless File.directory?(fzf_dir)
617
+ fzf = File.join(fzf_dir, 'bin/fzf')
618
+ return fzf if File.exist?(fzf)
619
+
620
+ Doing.logger.log_now(:warn, 'Compiling and installing FZF. This will only happen once')
621
+ Doing.logger.log_now(:warn, 'fzf is copyright Junegunn Choi <https://github.com/junegunn/fzf/blob/master/LICENSE>')
622
+
623
+ res = `#{fzf_dir}/install --bin --no-key-bindings --no-completion --no-update-rc --no-bash --no-zsh --no-fish`
624
+
625
+ raise DoingRuntimeError unless File.exist?(fzf)
626
+
627
+ fzf
628
+ end
629
+
614
630
  ##
615
631
  ## Generate a menu of options and allow user selection
616
632
  ##
@@ -619,7 +635,6 @@ module Doing
619
635
  def choose_from(options, prompt: 'Make a selection: ', multiple: false, sorted: true, fzf_args: [])
620
636
  return nil unless $stdout.isatty
621
637
 
622
- fzf = File.join(File.dirname(__FILE__), '../helpers/fuzzyfilefinder')
623
638
  # fzf_args << '-1' # User is expecting a menu, and even if only one it seves as confirmation
624
639
  fzf_args << %(--prompt "#{prompt}")
625
640
  fzf_args << '--multi' if multiple
@@ -653,8 +668,6 @@ module Doing
653
668
  def fuzzy_filter_items(items, opt: {})
654
669
  scannable = items.map.with_index { |item, idx| "#{item.title} #{item.note.join(' ')}".gsub(/[|*?!]/, '') + "|#{idx}" }.join("\n")
655
670
 
656
- fzf = File.join(File.dirname(__FILE__), '../helpers/fuzzyfilefinder')
657
-
658
671
  fzf_args = [
659
672
  '--multi',
660
673
  %(--filter="#{opt[:search].sub(/^'?/, "'")}"),
@@ -869,8 +882,6 @@ module Doing
869
882
  out.join('')
870
883
  end
871
884
 
872
- fzf = File.join(File.dirname(__FILE__), '../helpers/fuzzyfilefinder')
873
-
874
885
  fzf_args = [
875
886
  %(--header="#{opt[:header]}"),
876
887
  %(--prompt="#{opt[:prompt].sub(/ *$/, ' ')}"),
@@ -2187,7 +2198,8 @@ EOS
2187
2198
  output += list_section({ section: title, template: "\t- %date | %title%t2note", highlight: false, wrap_width: 0, tags_color: false })
2188
2199
  end
2189
2200
 
2190
- output + @other_content_bottom.join("\n") unless @other_content_bottom.nil?
2201
+ output += @other_content_bottom.join("\n") unless @other_content_bottom.nil?
2202
+ output.uncolor
2191
2203
  end
2192
2204
 
2193
2205
  ##
data/lib/doing.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  # frozen_string_literal: true
2
-
3
2
  require 'doing/version'
4
3
  require 'time'
5
4
  require 'date'
@@ -30,6 +29,7 @@ require 'doing/errors'
30
29
  require 'doing/hooks'
31
30
  require 'doing/plugin_manager'
32
31
  require 'doing/pager'
32
+ require 'doing/completion'
33
33
  # require 'doing/markdown_document_listener'
34
34
 
35
35
  # Main doing module
@@ -0,0 +1,119 @@
1
+ ---
2
+ project_name: fzf
3
+
4
+ before:
5
+ hooks:
6
+ - go mod download
7
+
8
+ builds:
9
+ - id: fzf-macos
10
+ binary: fzf
11
+ goos:
12
+ - darwin
13
+ goarch:
14
+ - amd64
15
+ ldflags:
16
+ - "-s -w -X main.version={{ .Version }} -X main.revision={{ .ShortCommit }}"
17
+ hooks:
18
+ post: |
19
+ sh -c '
20
+ cat > /tmp/fzf-gon-amd64.hcl << EOF
21
+ source = ["./dist/fzf-macos_darwin_amd64/fzf"]
22
+ bundle_id = "kr.junegunn.fzf"
23
+ apple_id {
24
+ username = "junegunn.c@gmail.com"
25
+ password = "@env:AC_PASSWORD"
26
+ }
27
+ sign {
28
+ application_identity = "Developer ID Application: Junegunn Choi (Y254DRW44Z)"
29
+ }
30
+ zip {
31
+ output_path = "./dist/fzf-{{ .Version }}-darwin_amd64.zip"
32
+ }
33
+ EOF
34
+ gon /tmp/fzf-gon-amd64.hcl
35
+ '
36
+
37
+ - id: fzf-macos-arm
38
+ binary: fzf
39
+ goos:
40
+ - darwin
41
+ goarch:
42
+ - arm64
43
+ ldflags:
44
+ - "-s -w -X main.version={{ .Version }} -X main.revision={{ .ShortCommit }}"
45
+ hooks:
46
+ post: |
47
+ sh -c '
48
+ cat > /tmp/fzf-gon-arm64.hcl << EOF
49
+ source = ["./dist/fzf-macos-arm_darwin_arm64/fzf"]
50
+ bundle_id = "kr.junegunn.fzf"
51
+ apple_id {
52
+ username = "junegunn.c@gmail.com"
53
+ password = "@env:AC_PASSWORD"
54
+ }
55
+ sign {
56
+ application_identity = "Developer ID Application: Junegunn Choi (Y254DRW44Z)"
57
+ }
58
+ zip {
59
+ output_path = "./dist/fzf-{{ .Version }}-darwin_arm64.zip"
60
+ }
61
+ EOF
62
+ gon /tmp/fzf-gon-arm64.hcl
63
+ '
64
+
65
+ - id: fzf
66
+ goos:
67
+ - linux
68
+ - windows
69
+ - freebsd
70
+ - openbsd
71
+ goarch:
72
+ - amd64
73
+ - arm
74
+ - arm64
75
+ goarm:
76
+ - 5
77
+ - 6
78
+ - 7
79
+ ldflags:
80
+ - "-s -w -X main.version={{ .Version }} -X main.revision={{ .ShortCommit }}"
81
+ ignore:
82
+ - goos: freebsd
83
+ goarch: arm
84
+ - goos: openbsd
85
+ goarch: arm
86
+ - goos: freebsd
87
+ goarch: arm64
88
+ - goos: openbsd
89
+ goarch: arm64
90
+
91
+ archives:
92
+ - name_template: "{{ .ProjectName }}-{{ .Version }}-{{ .Os }}_{{ .Arch }}{{ if .Arm }}v{{ .Arm }}{{ end }}"
93
+ builds:
94
+ - fzf
95
+ format: tar.gz
96
+ format_overrides:
97
+ - goos: windows
98
+ format: zip
99
+ files:
100
+ - non-existent*
101
+
102
+ release:
103
+ github:
104
+ owner: junegunn
105
+ name: fzf
106
+ prerelease: auto
107
+ name_template: '{{ .Tag }}'
108
+ extra_files:
109
+ - glob: ./dist/fzf-*darwin*.zip
110
+
111
+ snapshot:
112
+ name_template: "{{ .Tag }}-devel"
113
+
114
+ changelog:
115
+ sort: asc
116
+ filters:
117
+ exclude:
118
+ - README
119
+ - test
@@ -0,0 +1,28 @@
1
+ Layout/LineLength:
2
+ Enabled: false
3
+ Metrics:
4
+ Enabled: false
5
+ Lint/ShadowingOuterLocalVariable:
6
+ Enabled: false
7
+ Style/MethodCallWithArgsParentheses:
8
+ Enabled: true
9
+ IgnoredMethods:
10
+ - assert
11
+ - exit
12
+ - paste
13
+ - puts
14
+ - raise
15
+ - refute
16
+ - require
17
+ - send_keys
18
+ IgnoredPatterns:
19
+ - ^assert_
20
+ - ^refute_
21
+ Style/NumericPredicate:
22
+ Enabled: false
23
+ Style/StringConcatenation:
24
+ Enabled: false
25
+ Style/OptionalBooleanParameter:
26
+ Enabled: false
27
+ Style/WordArray:
28
+ MinSize: 1