na 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +8 -0
  3. data/Gemfile +2 -0
  4. data/Gemfile.lock +35 -0
  5. data/README.rdoc +6 -0
  6. data/Rakefile +31 -0
  7. data/bin/na +285 -0
  8. data/html/App.html +105 -0
  9. data/html/NA/Action.html +299 -0
  10. data/html/NA/Color.html +373 -0
  11. data/html/NA.html +100 -0
  12. data/html/README_rdoc.html +328 -0
  13. data/html/String.html +368 -0
  14. data/html/created.rid +9 -0
  15. data/html/css/fonts.css +167 -0
  16. data/html/css/rdoc.css +639 -0
  17. data/html/fonts/Lato-Light.ttf +0 -0
  18. data/html/fonts/Lato-LightItalic.ttf +0 -0
  19. data/html/fonts/Lato-Regular.ttf +0 -0
  20. data/html/fonts/Lato-RegularItalic.ttf +0 -0
  21. data/html/fonts/SourceCodePro-Bold.ttf +0 -0
  22. data/html/fonts/SourceCodePro-Regular.ttf +0 -0
  23. data/html/images/add.png +0 -0
  24. data/html/images/arrow_up.png +0 -0
  25. data/html/images/brick.png +0 -0
  26. data/html/images/brick_link.png +0 -0
  27. data/html/images/bug.png +0 -0
  28. data/html/images/bullet_black.png +0 -0
  29. data/html/images/bullet_toggle_minus.png +0 -0
  30. data/html/images/bullet_toggle_plus.png +0 -0
  31. data/html/images/date.png +0 -0
  32. data/html/images/delete.png +0 -0
  33. data/html/images/find.png +0 -0
  34. data/html/images/loadingAnimation.gif +0 -0
  35. data/html/images/macFFBgHack.png +0 -0
  36. data/html/images/package.png +0 -0
  37. data/html/images/page_green.png +0 -0
  38. data/html/images/page_white_text.png +0 -0
  39. data/html/images/page_white_width.png +0 -0
  40. data/html/images/plugin.png +0 -0
  41. data/html/images/ruby.png +0 -0
  42. data/html/images/tag_blue.png +0 -0
  43. data/html/images/tag_green.png +0 -0
  44. data/html/images/transparent.png +0 -0
  45. data/html/images/wrench.png +0 -0
  46. data/html/images/wrench_orange.png +0 -0
  47. data/html/images/zoom.png +0 -0
  48. data/html/index.html +297 -0
  49. data/html/js/darkfish.js +84 -0
  50. data/html/js/navigation.js +105 -0
  51. data/html/js/navigation.js.gz +0 -0
  52. data/html/js/search.js +110 -0
  53. data/html/js/search_index.js +1 -0
  54. data/html/js/search_index.js.gz +0 -0
  55. data/html/js/searcher.js +229 -0
  56. data/html/js/searcher.js.gz +0 -0
  57. data/html/table_of_contents.html +237 -0
  58. data/lib/na/action.rb +65 -0
  59. data/lib/na/colors.rb +335 -0
  60. data/lib/na/next_action.rb +181 -0
  61. data/lib/na/string.rb +42 -0
  62. data/lib/na/version.rb +3 -0
  63. data/lib/na.rb +11 -0
  64. data/na.gemspec +26 -0
  65. data/na.rdoc +167 -0
  66. metadata +211 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 2d4f45d14fddff26b88853edcac42f9d8250de1848f5d639138d757a0ce5bfe1
4
+ data.tar.gz: 73057d29cf56b1a3069973f5ea1ab4c06c4fcf76778997df12e51a56baf6ca0f
5
+ SHA512:
6
+ metadata.gz: 1cfcd9dcf3543954f558ac25438bf84384f7c41fdde3f20ec7b6ce8970f971841e940d84b5eb003c5aa26dd17b77fde85901c10b9c30cb179a39a7ea1e26ac07
7
+ data.tar.gz: 824e2b356c805301fefd096bc851979e307268bb3ddc4f581c74cf03a4b8cf17de688e329a039c8754f646af99e6944f217d4cdd2e02a676fe7763ed08e93a26
data/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ ### 1.0.0
2
+
3
+ 2022-09-27 10:45
4
+
5
+ #### IMPROVED
6
+
7
+ - Backwards compatibility with the Bash version of NA
8
+
data/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ source 'https://rubygems.org'
2
+ gemspec
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ na (1.0.0)
5
+ gli (~> 2.21.0)
6
+ tty-reader (~> 0.9, >= 0.9.0)
7
+ tty-which (~> 0.5, >= 0.5.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ gli (2.21.0)
13
+ minitest (5.16.3)
14
+ rake (0.9.6)
15
+ rdoc (4.3.0)
16
+ tty-cursor (0.7.1)
17
+ tty-reader (0.9.0)
18
+ tty-cursor (~> 0.7)
19
+ tty-screen (~> 0.8)
20
+ wisper (~> 2.0)
21
+ tty-screen (0.8.1)
22
+ tty-which (0.5.0)
23
+ wisper (2.0.1)
24
+
25
+ PLATFORMS
26
+ arm64-darwin-20
27
+
28
+ DEPENDENCIES
29
+ minitest (~> 5.14)
30
+ na!
31
+ rake (~> 0.9.2)
32
+ rdoc (~> 4.3)
33
+
34
+ BUNDLED WITH
35
+ 2.2.29
data/README.rdoc ADDED
@@ -0,0 +1,6 @@
1
+ = na
2
+
3
+ A command line tool for adding and listing project todos in TaskPaper format.
4
+
5
+ :include:na.rdoc
6
+
data/Rakefile ADDED
@@ -0,0 +1,31 @@
1
+ require 'rake/clean'
2
+ require 'rubygems'
3
+ require 'rubygems/package_task'
4
+ require 'rdoc/task'
5
+ require 'yard'
6
+
7
+ YARD::Rake::YardocTask.new do |t|
8
+ t.files = ['lib/doing/*.rb']
9
+ t.options = ['--markup-provider=redcarpet', '--markup=markdown', '--no-private', '-p', 'yard_templates']
10
+ # t.stats_options = ['--list-undoc']
11
+ end
12
+
13
+ task :doc, [*Rake.application[:yard].arg_names] => [:yard]
14
+
15
+ Rake::RDocTask.new do |rd|
16
+ rd.main = "README.rdoc"
17
+ rd.rdoc_files.include("README.rdoc","lib/**/*.rb","bin/**/*")
18
+ rd.title = 'Your application title'
19
+ end
20
+
21
+ spec = eval(File.read('na.gemspec'))
22
+
23
+ Gem::PackageTask.new(spec) do |pkg|
24
+ end
25
+ require 'rake/testtask'
26
+ Rake::TestTask.new do |t|
27
+ t.libs << "test"
28
+ t.test_files = FileList['test/*_test.rb']
29
+ end
30
+
31
+ task :default => :test
data/bin/na ADDED
@@ -0,0 +1,285 @@
1
+ #!/usr/bin/env ruby
2
+ $LOAD_PATH.unshift File.join(__dir__, '..', 'lib')
3
+ require 'gli'
4
+ require 'na'
5
+
6
+ class App
7
+ extend GLI::App
8
+
9
+ program_desc 'Add and list next actions for the current project'
10
+
11
+ version Na::VERSION
12
+ hide_commands_without_desc true
13
+ autocomplete_commands false
14
+ wrap_help_text :one_line unless $stdout.isatty
15
+
16
+ config_file '.na.rc'
17
+
18
+ desc 'File extension to consider a todo file'
19
+ default_value 'taskpaper'
20
+ arg_name 'FILE_EXTENSION'
21
+ flag :ext
22
+
23
+ desc 'Tag to consider a next action'
24
+ default_value 'na'
25
+ arg_name 'TAG'
26
+ flag :na_tag
27
+
28
+ default_command :next
29
+
30
+ NA::Color.coloring = $stdin.isatty
31
+
32
+ desc 'Add a next action (deprecated, for backwards compatibility)'
33
+ switch %i[a add]
34
+
35
+ desc 'Set a priority 0-5 (deprecated, for backwards compatibility)'
36
+ arg_name 'PRIORITY'
37
+ flag %i[p priority]
38
+
39
+ desc 'Prompt for additional notes (deprecated, for backwards compatibility)'
40
+ switch %i[n note]
41
+
42
+ desc 'Recurse 3 directories deep (deprecated, for backwards compatability)'
43
+ switch %i[r recurse], default_value: false, negatable: true
44
+
45
+ desc 'Recurse to depth'
46
+ arg_name 'DEPTH'
47
+ default_value 1
48
+ flag %i[d depth], type: :integer, must_match: /^\d+$/
49
+
50
+ desc 'Show next actions'
51
+ command %i[next show] do |c|
52
+ c.desc 'Recurse to depth'
53
+ c.arg_name 'DEPTH'
54
+ c.flag %i[d depth], type: :integer, must_match: /^\d+$/
55
+
56
+ c.desc 'Alternate tag to search for'
57
+ c.default_value 'na'
58
+ c.flag %i[t tag]
59
+
60
+ c.action do |global_options, options, _|
61
+ if global_options[:add]
62
+ cmd = ['add']
63
+ cmd.push('--note') if global_options[:note]
64
+ cmd.concat(['--priority', global_options[:priority]]) if global_options[:priority]
65
+ cmd.push(ARGV.unshift(@command))
66
+ p cmd
67
+ exit run(cmd)
68
+ end
69
+
70
+ depth = if global_options[:recurse] && options[:depth].nil? && global_options[:depth] == 1
71
+ 3
72
+ else
73
+ options[:depth].nil? ? global_options[:depth].to_i : options[:depth].to_i
74
+ end
75
+ tag = options[:tag] == global_options[:na_tag] ? nil : options[:tag]
76
+ actions = NA.parse_actions(depth: depth,
77
+ extension: global_options[:ext],
78
+ na_tag: global_options[:na_tag],
79
+ tag: tag)
80
+ NA.output_actions(actions, depth, global_options[:ext])
81
+ end
82
+ end
83
+
84
+ desc 'Add a new next action'
85
+ arg_name 'TASK'
86
+ command :add do |c|
87
+ c.desc 'Prompt for additional notes'
88
+ c.switch %i[n note]
89
+
90
+ c.desc 'Add a priority level 1-5'
91
+ c.flag %i[p priority], must_match: /[1-5]/, type: :integer, default_value: 0
92
+
93
+ c.desc 'Use a tag other than the default next action tag'
94
+ c.arg_name 'TAG'
95
+ c.flag %i[t tag]
96
+
97
+ c.desc 'Specify the file to which the task should be added'
98
+ c.arg_name 'PATH'
99
+ c.flag %i[f file]
100
+
101
+ c.action do |global_options, options, args|
102
+ reader = TTY::Reader.new
103
+ action = if args.count.positive?
104
+ args.join(' ').strip
105
+ elsif TTY::Which.exist?('gum')
106
+ `gum input --placeholder "Enter a task"`.strip
107
+ else
108
+ puts NA::Color.template('{bm}Enter task:{x}')
109
+ reader.read_line(NA::Color.template('{by}> {bw}')).strip
110
+ end
111
+
112
+ if action.nil? || action.empty?
113
+ puts 'Empty input, cancelled'
114
+ Process.exit 1
115
+ end
116
+
117
+ if options[:priority]&.to_i&.positive?
118
+ action = "#{action.gsub(/@priority\(\d+\)/, '')} @priority(#{options[:priority]})"
119
+ end
120
+
121
+ na_tag = global_options[:na_tag]
122
+ na_tag = options[:tag] unless options[:tag].nil?
123
+
124
+ action = "#{action.gsub(/@#{na_tag}/, '')} @#{na_tag}"
125
+
126
+ note = if options[:note]
127
+ if TTY::Which.exist?('gum')
128
+ `gum write --placeholder "Enter a note, CTRL-d to save" --width $(tput cols) --char-limit 0`.strip.split("\n")
129
+ else
130
+ puts NA::Color.template('{bm}Enter a note, {bw}CTRL-d{bm} to end editing{bw}')
131
+ reader.read_multiline
132
+ end
133
+ end
134
+ if options[:file]
135
+ target = File.expand_path(options[:file])
136
+ unless File.exist?(target)
137
+ print NA::Color.template('{by}Specified file not found, create it? {w}(y/{g}N{w}){x} ')
138
+ res = reader.read_char
139
+ if res =~ /y/i
140
+ basename = File.basename(target, ".#{global_options[:ext]}")
141
+ NA.create_todo(target, basename)
142
+ else
143
+ puts NA::Color.template('{r}Cancelled{x}')
144
+ Process.exit 1
145
+ end
146
+ end
147
+ else
148
+ files = NA.find_files(depth: 1, extension: global_options[:ext])
149
+ if files.count == 0
150
+ print NA::Color.template('{by}No todo file found, create one? {w}(y/{g}N{w}){x} ')
151
+ res = reader.read_char
152
+ if res =~ /y/i
153
+ basename = File.expand_path('.').split('/').last
154
+ target = "#{basename}.#{global_options[:ext]}"
155
+ NA.create_todo(target, basename)
156
+ files = NA.find_files(depth: 1, extension: global_options[:ext])
157
+ end
158
+ end
159
+ target = files.count > 1 ? NA.select_file(files) : files[0]
160
+ unless files.count.positive? && File.exist?(target)
161
+ puts NA::Color.template('{r}Cancelled{x}')
162
+ Process.exit 1
163
+ end
164
+ end
165
+
166
+ NA.add_action(target, action, note)
167
+ end
168
+ end
169
+
170
+ desc 'Find actions matching a search pattern'
171
+ long_desc 'Search tokens are separated by spaces. Actions matching any token in the pattern will be shown
172
+ (partial matches allowed). Add a + before a token to make it required, e.g. `na find +feature +maybe`'
173
+ arg_name 'PATTERN'
174
+ command %i[find] do |c|
175
+ c.desc 'Match pattern exactly'
176
+ c.switch %i[x exact]
177
+
178
+ c.desc 'Recurse to depth'
179
+ c.arg_name 'DEPTH'
180
+ c.default_value 1
181
+ c.flag %i[d depth], type: :integer, must_match: /^\d+$/
182
+
183
+ c.action do |global_options, options, args|
184
+ depth = if global_options[:recurse] && options[:depth].nil? && global_options[:depth] == 1
185
+ 3
186
+ else
187
+ options[:depth].nil? ? global_options[:depth].to_i : options[:depth].to_i
188
+ end
189
+ tokens = nil
190
+ if options[:exact]
191
+ tokens = args.join(' ')
192
+ else
193
+ tokens = []
194
+ args.each do |arg|
195
+ m = arg.match(/^(?<req>\+)?(?<tok>.*?)$/)
196
+ tokens.push({
197
+ token: m['tok'],
198
+ required: !m['req'].nil?
199
+ })
200
+ end
201
+ end
202
+
203
+ actions = NA.parse_actions(depth: depth,
204
+ extension: global_options[:ext],
205
+ na_tag: global_options[:na_tag],
206
+ search: tokens)
207
+ NA.output_actions(actions, depth, global_options[:ext])
208
+ end
209
+ end
210
+
211
+
212
+ desc 'Find actions matching a tag'
213
+ long_desc 'Finds actions with tags matching the arguments. An action is shown if it
214
+ contains any of the tags listed. Add a + before a tag to make it required,
215
+ e.g. `na tagged feature +maybe`'
216
+ arg_name 'TAG [VALUE]'
217
+ command %i[tagged] do |c|
218
+ c.desc 'Recurse to depth'
219
+ c.arg_name 'DEPTH'
220
+ c.default_value 1
221
+ c.flag %i[d depth], type: :integer, must_match: /^\d+$/
222
+
223
+ c.action do |global_options, options, args|
224
+ depth = if global_options[:recurse] && options[:depth].nil? && global_options[:depth] == 1
225
+ 3
226
+ else
227
+ options[:depth].nil? ? global_options[:depth].to_i : options[:depth].to_i
228
+ end
229
+
230
+ tags = []
231
+ args.each do |arg|
232
+ # TODO: <> comparisons do nothing right now
233
+ m = arg.match(/^(?<req>\+)?(?<tag>[^ =<>]+)(?:(?<op>[=<>]+)(?<val>\S+))?$/)
234
+ tags.push({
235
+ tag: m['tag'],
236
+ comp: m['op'],
237
+ value: m['val'],
238
+ required: !m['req'].nil?
239
+ })
240
+ end
241
+
242
+ actions = NA.parse_actions(depth: depth,
243
+ extension: global_options[:ext],
244
+ na_tag: global_options[:na_tag],
245
+ tag: tags)
246
+ NA.output_actions(actions, depth, global_options[:ext])
247
+ end
248
+ end
249
+
250
+ pre do |global,command,options,args|
251
+ # Pre logic here
252
+ # Return true to proceed; false to abort and not call the
253
+ # chosen command
254
+ # Use skips_pre before a command to skip this block
255
+ # on that command only
256
+ true
257
+ end
258
+
259
+ post do |global,command,options,args|
260
+ # Post logic here
261
+ # Use skips_post before a command to skip this
262
+ # block on that command only
263
+ end
264
+
265
+ on_error do |exception|
266
+ case exception
267
+ when GLI::UnknownCommand
268
+ cmd = ['add']
269
+ if ARGV.count.positive?
270
+ cmd.concat(ARGV.unshift($first_arg))
271
+ end
272
+ p cmd
273
+ exit run(cmd)
274
+ when SystemExit
275
+ false
276
+ else
277
+ true
278
+ end
279
+ end
280
+ end
281
+
282
+ @command = ARGV[0]
283
+ $first_arg = ARGV[1]
284
+
285
+ exit App.run(ARGV)
data/html/App.html ADDED
@@ -0,0 +1,105 @@
1
+ <!DOCTYPE html>
2
+
3
+ <html>
4
+ <head>
5
+ <meta charset="UTF-8">
6
+
7
+ <title>class App - Your application title</title>
8
+
9
+ <script type="text/javascript">
10
+ var rdoc_rel_prefix = "./";
11
+ var index_rel_prefix = "./";
12
+ </script>
13
+
14
+ <script src="./js/navigation.js" defer></script>
15
+ <script src="./js/search.js" defer></script>
16
+ <script src="./js/search_index.js" defer></script>
17
+ <script src="./js/searcher.js" defer></script>
18
+ <script src="./js/darkfish.js" defer></script>
19
+
20
+ <link href="./css/fonts.css" rel="stylesheet">
21
+ <link href="./css/rdoc.css" rel="stylesheet">
22
+
23
+
24
+ <body id="top" role="document" class="class">
25
+ <nav role="navigation">
26
+ <div id="project-navigation">
27
+ <div id="home-section" role="region" title="Quick navigation" class="nav-section">
28
+ <h2>
29
+ <a href="./index.html" rel="home">Home</a>
30
+ </h2>
31
+
32
+ <div id="table-of-contents-navigation">
33
+ <a href="./table_of_contents.html#pages">Pages</a>
34
+ <a href="./table_of_contents.html#classes">Classes</a>
35
+ <a href="./table_of_contents.html#methods">Methods</a>
36
+ </div>
37
+ </div>
38
+
39
+ <div id="search-section" role="search" class="project-section initially-hidden">
40
+ <form action="#" method="get" accept-charset="utf-8">
41
+ <div id="search-field-wrapper">
42
+ <input id="search-field" role="combobox" aria-label="Search"
43
+ aria-autocomplete="list" aria-controls="search-results"
44
+ type="text" name="search" placeholder="Search" spellcheck="false"
45
+ title="Type to search, Up and Down to navigate, Enter to load">
46
+ </div>
47
+
48
+ <ul id="search-results" aria-label="Search Results"
49
+ aria-busy="false" aria-expanded="false"
50
+ aria-atomic="false" class="initially-hidden"></ul>
51
+ </form>
52
+ </div>
53
+
54
+ </div>
55
+
56
+
57
+
58
+ <div id="class-metadata">
59
+
60
+
61
+ <div id="parent-class-section" class="nav-section">
62
+ <h3>Parent</h3>
63
+
64
+ <p class="link">Object
65
+ </div>
66
+
67
+
68
+
69
+ <div id="extends-section" class="nav-section">
70
+ <h3>Extended With Modules</h3>
71
+
72
+ <ul class="link-list">
73
+ <li><span class="extend">GLI::App</span>
74
+ </ul>
75
+ </div>
76
+
77
+
78
+ </div>
79
+ </nav>
80
+
81
+ <main role="main" aria-labelledby="class-App">
82
+ <h1 id="class-App" class="class">
83
+ class App
84
+ </h1>
85
+
86
+ <section class="description">
87
+
88
+ </section>
89
+
90
+ <section id="5Buntitled-5D" class="documentation-section">
91
+
92
+
93
+
94
+
95
+
96
+ </section>
97
+ </main>
98
+
99
+
100
+ <footer id="validator-badges" role="contentinfo">
101
+ <p><a href="https://validator.w3.org/check/referer">Validate</a>
102
+ <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.3.3.
103
+ <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.
104
+ </footer>
105
+