na 1.0.0 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +21 -1
  3. data/Gemfile.lock +6 -1
  4. data/LICENSE.txt +19 -0
  5. data/README.md +272 -0
  6. data/Rakefile +48 -2
  7. data/bin/na +40 -5
  8. data/lib/na/next_action.rb +55 -2
  9. data/lib/na/version.rb +1 -1
  10. data/lib/na.rb +2 -0
  11. data/na.gemspec +10 -3
  12. data/na.rdoc +6 -2
  13. data/scripts/fixreadme.rb +18 -0
  14. data/src/README.md +276 -0
  15. metadata +54 -56
  16. data/html/App.html +0 -105
  17. data/html/NA/Action.html +0 -299
  18. data/html/NA/Color.html +0 -373
  19. data/html/NA.html +0 -100
  20. data/html/README_rdoc.html +0 -328
  21. data/html/String.html +0 -368
  22. data/html/created.rid +0 -9
  23. data/html/css/fonts.css +0 -167
  24. data/html/css/rdoc.css +0 -639
  25. data/html/fonts/Lato-Light.ttf +0 -0
  26. data/html/fonts/Lato-LightItalic.ttf +0 -0
  27. data/html/fonts/Lato-Regular.ttf +0 -0
  28. data/html/fonts/Lato-RegularItalic.ttf +0 -0
  29. data/html/fonts/SourceCodePro-Bold.ttf +0 -0
  30. data/html/fonts/SourceCodePro-Regular.ttf +0 -0
  31. data/html/images/add.png +0 -0
  32. data/html/images/arrow_up.png +0 -0
  33. data/html/images/brick.png +0 -0
  34. data/html/images/brick_link.png +0 -0
  35. data/html/images/bug.png +0 -0
  36. data/html/images/bullet_black.png +0 -0
  37. data/html/images/bullet_toggle_minus.png +0 -0
  38. data/html/images/bullet_toggle_plus.png +0 -0
  39. data/html/images/date.png +0 -0
  40. data/html/images/delete.png +0 -0
  41. data/html/images/find.png +0 -0
  42. data/html/images/loadingAnimation.gif +0 -0
  43. data/html/images/macFFBgHack.png +0 -0
  44. data/html/images/package.png +0 -0
  45. data/html/images/page_green.png +0 -0
  46. data/html/images/page_white_text.png +0 -0
  47. data/html/images/page_white_width.png +0 -0
  48. data/html/images/plugin.png +0 -0
  49. data/html/images/ruby.png +0 -0
  50. data/html/images/tag_blue.png +0 -0
  51. data/html/images/tag_green.png +0 -0
  52. data/html/images/transparent.png +0 -0
  53. data/html/images/wrench.png +0 -0
  54. data/html/images/wrench_orange.png +0 -0
  55. data/html/images/zoom.png +0 -0
  56. data/html/index.html +0 -297
  57. data/html/js/darkfish.js +0 -84
  58. data/html/js/navigation.js +0 -105
  59. data/html/js/navigation.js.gz +0 -0
  60. data/html/js/search.js +0 -110
  61. data/html/js/search_index.js +0 -1
  62. data/html/js/search_index.js.gz +0 -0
  63. data/html/js/searcher.js +0 -229
  64. data/html/js/searcher.js.gz +0 -0
  65. data/html/table_of_contents.html +0 -237
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2d4f45d14fddff26b88853edcac42f9d8250de1848f5d639138d757a0ce5bfe1
4
- data.tar.gz: 73057d29cf56b1a3069973f5ea1ab4c06c4fcf76778997df12e51a56baf6ca0f
3
+ metadata.gz: 17064787b8afa01f88d01971b93f9f28593f40666ff8c2d49ecd52dff678654c
4
+ data.tar.gz: f14105b3e652e320b91022a6d4fb6c8cafc0811e6bbc5f7a0888b915e1ba1f99
5
5
  SHA512:
6
- metadata.gz: 1cfcd9dcf3543954f558ac25438bf84384f7c41fdde3f20ec7b6ce8970f971841e940d84b5eb003c5aa26dd17b77fde85901c10b9c30cb179a39a7ea1e26ac07
7
- data.tar.gz: 824e2b356c805301fefd096bc851979e307268bb3ddc4f581c74cf03a4b8cf17de688e329a039c8754f646af99e6944f217d4cdd2e02a676fe7763ed08e93a26
6
+ metadata.gz: e01fa0fc9027be241d59414d555661df5f1794db2b30fa969562f7db08f22ae1abcd4289f69178a839cb18f4077213b3ae4ee106a776325016633af9f4c6cf12
7
+ data.tar.gz: a13918d2f66aba2b5d84622e33bb60d9404c0795b5ad6c0badcee1ea3e6fe523168d8bdcb46bc45b2fb15df7a62cc54e5f630c9f7c01929982b09fc25b60da79
data/CHANGELOG.md CHANGED
@@ -1,8 +1,28 @@
1
+ ### 1.0.2
2
+
3
+ 2022-09-27 14:18
4
+
5
+ #### IMPROVED
6
+
7
+ - When using gum input, make the input field the width of the terminal
8
+
9
+ #### FIXED
10
+
11
+ - -a with no arguments will work for backward compatability
12
+
13
+ ### 1.0.1
14
+
15
+ 2022-09-27 12:52
16
+
17
+ #### NEW
18
+
19
+ - Add arguments to `na next` to query previously-seen na files in other directories
20
+
1
21
  ### 1.0.0
2
22
 
3
23
  2022-09-27 10:45
4
24
 
5
25
  #### IMPROVED
6
26
 
27
+ - Initial rewrite from Bash script to Ruby gem
7
28
  - Backwards compatibility with the Bash version of NA
8
-
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- na (1.0.0)
4
+ na (1.0.2)
5
5
  gli (~> 2.21.0)
6
6
  tty-reader (~> 0.9, >= 0.9.0)
7
+ tty-screen (~> 0.8, >= 0.8.1)
7
8
  tty-which (~> 0.5, >= 0.5.0)
8
9
 
9
10
  GEM
@@ -20,7 +21,10 @@ GEM
20
21
  wisper (~> 2.0)
21
22
  tty-screen (0.8.1)
22
23
  tty-which (0.5.0)
24
+ webrick (1.7.0)
23
25
  wisper (2.0.1)
26
+ yard (0.9.28)
27
+ webrick (~> 1.7.0)
24
28
 
25
29
  PLATFORMS
26
30
  arm64-darwin-20
@@ -30,6 +34,7 @@ DEPENDENCIES
30
34
  na!
31
35
  rake (~> 0.9.2)
32
36
  rdoc (~> 4.3)
37
+ yard (~> 0.9, >= 0.9.26)
33
38
 
34
39
  BUNDLED WITH
35
40
  2.2.29
data/LICENSE.txt ADDED
@@ -0,0 +1,19 @@
1
+ MIT License Copyright (c) 2022 Brett Terpstra
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is furnished
8
+ to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice (including the next
11
+ paragraph) shall be included in all copies or substantial portions of the
12
+ Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
17
+ OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
18
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
19
+ OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,272 @@
1
+ # na
2
+
3
+ [![Gem](https://img.shields.io/gem/v/na.svg)](https://rubygems.org/gems/na)
4
+ [![Travis](https://app.travis-ci.com/ttscoff/na_gem.svg?branch=main)](https://travis-ci.org/makenew/na_gem)
5
+ [![GitHub license](https://img.shields.io/github/license/ttscoff/na_gem.svg)](./LICENSE.txt)
6
+
7
+ **A command line tool for adding and listing per-project todos.**
8
+
9
+ _If you're one of the rare people like me who find this useful, feel free to
10
+ [buy me some coffee][donate]._
11
+
12
+ The current version of `na` is 1.0.1.
13
+
14
+ `na` ("next action") is a command line tool designed to make it easy to see what your next actions are for any project, right from the command line. It works with TaskPaper-formatted files (but any plain text format will do), looking for `@na` tags (or whatever you specify) in todo files in your current folder.
15
+
16
+ Used with Taskpaper files, it can add new todo items quickly from the command line, automatically tagging them as next actions.
17
+
18
+ It can also auto-display next actions when you enter a project directory, automatically locating any todo files and listing their next actions when you `cd` to the project (optionally recursive). See the [Prompt Hooks](#prompt-hooks) section for details.
19
+
20
+ ### Features
21
+
22
+ You can list next actions in files in the current directory by typing `na`. By default, `na` looks for `*.taskpaper` files and extracts items tagged `@na` and not `@done`. All of these can be changed in the configuration.
23
+
24
+ #### Easy matching
25
+
26
+ `na` features intelligent project matching. Every time it locates a todo file, it adds the project to the database. Once a project is recorded, you can list its actions by using any portion of the parent directories or file names. If your project is in `~/Sites/dev/markedapp`, you could quickly list its next actions by typing `na dev mark`. It will always look for the shortest match.
27
+
28
+ #### Recursion
29
+
30
+ `na` can also recurse subdirectories to find all todo files in child folders as well. Use the `-d X` to search X levels deep from the current directory. `na -r` with no arguments will recurse from your current location, looking for todo files 3 directories deep.
31
+
32
+ #### Adding todos
33
+
34
+ You can also quickly add todo items from the command line with the `add` subcommand. The script will look for a file in the current directory with a `.taskpaper` extension (configurable).
35
+
36
+ If found, it will try to locate an `Inbox:` project, or create one if it doesn't exist. Any arguments after `add` will be combined to create a new task in TaskPaper format. They will automatically be assigned as next actions (tagged `@na`) and will show up when `na` lists the tasks for the project.
37
+
38
+ ### Installation
39
+
40
+ Assuming you have Ruby and RubyGems installed, you can just run `gem install na`. If you run into errors, use `sudo gem install na`.
41
+
42
+ If you don't have Ruby/RubyGems, you can install them pretty easily with Homebrew, rvm, or asdf. I can't swear this tool is worth the time, but there _are_ a lot of great gems available...
43
+
44
+
45
+
46
+ ### Usage
47
+
48
+ ```
49
+ NAME
50
+ na - Add and list next actions for the current project
51
+
52
+
53
+ SYNOPSIS
54
+ na [global options] command [command options] [arguments...]
55
+
56
+
57
+ VERSION
58
+ 1.0.2
59
+
60
+
61
+
62
+ GLOBAL OPTIONS
63
+ -a, --[no-]add - Add a next action (deprecated, for backwards compatibility)
64
+ -d, --depth=DEPTH - Recurse to depth (default: 1)
65
+ --ext=FILE_EXTENSION - File extension to consider a todo file (default: taskpaper)
66
+ --help - Show this message
67
+ -n, --[no-]note - Prompt for additional notes (deprecated, for backwards compatibility)
68
+ --na_tag=TAG - Tag to consider a next action (default: na)
69
+ -p, --priority=PRIORITY - Set a priority 0-5 (deprecated, for backwards compatibility) (default: none)
70
+ -r, --[no-]recurse - Recurse 3 directories deep (deprecated, for backwards compatability)
71
+ --version - Display the program version
72
+
73
+
74
+
75
+ COMMANDS
76
+ add - Add a new next action
77
+ find - Find actions matching a search pattern
78
+ help - Shows a list of commands or help for one command
79
+ initconfig - Initialize the config file using current global options
80
+ next, show - Show next actions
81
+ tagged - Find actions matching a tag
82
+ ```
83
+
84
+ #### Commands
85
+
86
+ ##### add
87
+
88
+ Example: `na add This feature @idea I have`
89
+
90
+ ```
91
+ NAME
92
+ add - Add a new next action
93
+
94
+ SYNOPSIS
95
+
96
+ na [global options] add [command options] TASK
97
+
98
+ DESCRIPTION
99
+ Provides an easy way to store todos while you work. Add quick reminders and (if you set up Prompt Hooks) they'll automatically display next time you enter the directory. If multiple todo files are found in the current directory, a menu will allow you to pick to which file the action gets added.
100
+
101
+ COMMAND OPTIONS
102
+ -f, --file=PATH - Specify the file to which the task should be added (default: none)
103
+ -n, --[no-]note - Prompt for additional notes
104
+ -p, --priority=arg - Add a priority level 1-5 (default: 0)
105
+ -t, --tag=TAG - Use a tag other than the default next action tag (default: none)
106
+
107
+ EXAMPLES
108
+
109
+ # Add a new action to the Inbox, including a tag
110
+ na add "A cool feature I thought of @idea"
111
+
112
+ # Add a new action to the Inbox, set its @priority to 4, and prompt for an additional note
113
+ na add "A bug I need to fix" -p 4 -n
114
+ ```
115
+
116
+ ##### find
117
+
118
+ Example: `na find cool feature idea`
119
+
120
+ ```
121
+ NAME
122
+ find - Find actions matching a search pattern
123
+
124
+ SYNOPSIS
125
+
126
+ na [global options] find [command options] PATTERN
127
+
128
+ DESCRIPTION
129
+ Search tokens are separated by spaces. Actions matching any token in the pattern will be shown (partial matches allowed). Add a + before a token to make it required, e.g. `na find +feature +maybe`
130
+
131
+ COMMAND OPTIONS
132
+ -d, --depth=DEPTH - Recurse to depth (default: 1)
133
+ -x, --[no-]exact - Match pattern exactly
134
+
135
+ EXAMPLES
136
+
137
+ # Find all actions containing feature, idea, and swift
138
+ na find feature +idea +swift
139
+
140
+ # Find all actions containing the exact text "feature idea"
141
+ na find -x feature idea
142
+
143
+ # Find all actions 3 directories deep containing either swift or obj-c
144
+ na find -d 3 swift obj-c
145
+ ```
146
+
147
+ ##### next, show
148
+
149
+ Examples:
150
+
151
+ - `na show` (list all next actions in the current directory)
152
+ - `na show -d 3` (list all next actions in the current directory and look for additional files 3 levels deep from there)
153
+ - `na show marked2` (show next actions from another directory you've previously used na on)
154
+
155
+ ```
156
+ NAME
157
+ next - Show next actions
158
+
159
+ SYNOPSIS
160
+
161
+ na [global options] next [command options] OPTIONAL_QUERY
162
+
163
+ COMMAND OPTIONS
164
+ -d, --depth=DEPTH - Recurse to depth (default: none)
165
+ -t, --tag=arg - Alternate tag to search for (default: na)
166
+
167
+ EXAMPLES
168
+
169
+ # display the next actions from any todo files in the current directory
170
+ doing next
171
+
172
+ # display the next actions from the current directory and its children, 3 levels deep
173
+ doing next -d 3
174
+ ```
175
+
176
+ ##### tagged
177
+
178
+ Example: `na tagged feature +maybe`
179
+
180
+ ```
181
+ NAME
182
+ tagged - Find actions matching a tag
183
+
184
+ SYNOPSIS
185
+
186
+ na [global options] tagged [command options] TAG [VALUE]
187
+
188
+ DESCRIPTION
189
+ Finds actions with tags matching the arguments. An action is shown if it contains any of the tags listed. Add a + before a tag to make it required, e.g. `na tagged feature +maybe`
190
+
191
+ COMMAND OPTIONS
192
+ -d, --depth=DEPTH - Recurse to depth (default: 1)
193
+
194
+ EXAMPLES
195
+
196
+ # Show all actions tagged @maybe
197
+ na tagged +maybe
198
+
199
+ # Show all actions tagged either @feature or @idea, recurse 3 levels
200
+ na tagged -d 3 feature idea
201
+ ```
202
+
203
+ ### Configuration
204
+
205
+ Global options such as todo extension and default next action tag can be stored permanently by using the `na initconfig` command. Run na with the global options you'd like to set, and add `initconfig` at the end of the command. A file will be written to `~/.na.rc`. You can edit this manually, or just update it using the `initconfig --force` command to overwrite it with new settings.
206
+
207
+ Example: `na --ext md --na_tag next initconfig --force`
208
+
209
+ When this command is run, it doesn't include options for subcommands, but inserts placeholders for them. If you want to permanently set an option for a subcommand, you'll need to edit `~/.na.rc`. For example, if you wanted the `next` command to always recurse 2 levels deep, you could edit it to look like this:
210
+
211
+ ```yaml
212
+ ---
213
+ :ext: taskpaper
214
+ :na_tag: na
215
+ :d: 1
216
+ commands:
217
+ :next:
218
+ :depth: 2
219
+ :add: {}
220
+ :find: {}
221
+ :tagged: {}
222
+ ```
223
+
224
+ Note that I created a new YAML dictionary inside of the `:next:` command, and added a `:depth:` key that matches the setting I want to make permanent.
225
+
226
+ > **WARNING** Don't touch most of the settings at the top of the auto-generated file. Setting any of them to true will alter the way na interprets the commands you're running. Most of those options are there for backwards compatibility with the bash version of this tool and will eventually be removed.
227
+
228
+
229
+ ### Prompt Hooks
230
+
231
+ You can add a prompt command to your shell to have na automatically list your next actions when you `cd` into a directory. Add the appropriate command to your login file for your shell:
232
+
233
+ _(You can add `-r` to any of these calls to na to automatically recurse 3 directories deep)_
234
+
235
+ Bash (in ~/.bash_profile):
236
+
237
+ ```bash
238
+ last_command_was_cd() {
239
+ [[ $(history 1|sed -e "s/^[ ]*[0-9]*[ ]*//") =~ ^((cd|z|j|jump|g|f|pushd|popd|exit)([ ]|$)) ]] && na
240
+ }
241
+ if [[ -z "$PROMPT_COMMAND" ]]; then
242
+ PROMPT_COMMAND="eval 'last_command_was_cd'"
243
+ else
244
+ echo $PROMPT_COMMAND | grep -v -q "last_command_was_cd" && PROMPT_COMMAND="$PROMPT_COMMAND;"'eval "last_command_was_cd"'
245
+ fi
246
+ ```
247
+
248
+ Fish (in ~/.config/fish/conf.d/*.fish):
249
+
250
+ ```fish
251
+ function __should_na --on-variable PWD
252
+ # function __should_na --on-event fish_prompt
253
+ test -s (basename $PWD)".taskpaper" && na
254
+ end
255
+ ```
256
+
257
+ Zsh (in ~/.zshrc):
258
+
259
+ ```zsh
260
+ chpwd() { na }
261
+ ```
262
+
263
+
264
+ ### Misc
265
+
266
+ If you have [gum][] installed, na will use it for command line input when adding tasks and notes.
267
+
268
+ [gum]: https://github.com/charmbracelet/gum
269
+ [donate]: http://brettterpstra.com/donate/
270
+ [github]: https://github.com/ttscoff/na_gem/
271
+
272
+ PayPal link: [paypal.me/ttscoff](https://paypal.me/ttscoff)
data/Rakefile CHANGED
@@ -5,7 +5,7 @@ require 'rdoc/task'
5
5
  require 'yard'
6
6
 
7
7
  YARD::Rake::YardocTask.new do |t|
8
- t.files = ['lib/doing/*.rb']
8
+ t.files = ['lib/na/*.rb']
9
9
  t.options = ['--markup-provider=redcarpet', '--markup=markdown', '--no-private', '-p', 'yard_templates']
10
10
  # t.stats_options = ['--list-undoc']
11
11
  end
@@ -28,4 +28,50 @@ Rake::TestTask.new do |t|
28
28
  t.test_files = FileList['test/*_test.rb']
29
29
  end
30
30
 
31
- task :default => :test
31
+ desc 'Development version check'
32
+ task :ver do
33
+ gver = `git ver`
34
+ cver = IO.read(File.join(File.dirname(__FILE__), 'CHANGELOG.md')).match(/^#+ (\d+\.\d+\.\d+(\w+)?)/)[1]
35
+ res = `grep VERSION lib/na/version.rb`
36
+ version = res.match(/VERSION *= *['"](\d+\.\d+\.\d+(\w+)?)/)[1]
37
+ puts "git tag: #{gver}"
38
+ puts "version.rb: #{version}"
39
+ puts "changelog: #{cver}"
40
+ end
41
+
42
+ desc 'Changelog version check'
43
+ task :cver do
44
+ puts IO.read(File.join(File.dirname(__FILE__), 'CHANGELOG.md')).match(/^#+ (\d+\.\d+\.\d+(\w+)?)/)[1]
45
+ end
46
+
47
+ desc 'Bump incremental version number'
48
+ task :bump, :type do |_, args|
49
+ args.with_defaults(type: 'inc')
50
+ version_file = 'lib/na/version.rb'
51
+ content = IO.read(version_file)
52
+ content.sub!(/VERSION = '(?<major>\d+)\.(?<minor>\d+)\.(?<inc>\d+)(?<pre>\S+)?'/) do
53
+ m = Regexp.last_match
54
+ major = m['major'].to_i
55
+ minor = m['minor'].to_i
56
+ inc = m['inc'].to_i
57
+ pre = m['pre']
58
+
59
+ case args[:type]
60
+ when /^maj/
61
+ major += 1
62
+ minor = 0
63
+ inc = 0
64
+ when /^min/
65
+ minor += 1
66
+ inc = 0
67
+ else
68
+ inc += 1
69
+ end
70
+
71
+ $stdout.puts "At version #{major}.#{minor}.#{inc}#{pre}"
72
+ "VERSION = '#{major}.#{minor}.#{inc}#{pre}'"
73
+ end
74
+ File.open(version_file, 'w+') { |f| f.puts content }
75
+ end
76
+
77
+ task default: %i[test clobber package]
data/bin/na CHANGED
@@ -48,7 +48,11 @@ class App
48
48
  flag %i[d depth], type: :integer, must_match: /^\d+$/
49
49
 
50
50
  desc 'Show next actions'
51
+ arg_name 'OPTIONAL_QUERY'
51
52
  command %i[next show] do |c|
53
+ c.example 'doing next', desc: 'display the next actions from any todo files in the current directory'
54
+ c.example 'doing next -d 3', desc: 'display the next actions from the current directory and its children, 3 levels deep'
55
+
52
56
  c.desc 'Recurse to depth'
53
57
  c.arg_name 'DEPTH'
54
58
  c.flag %i[d depth], type: :integer, must_match: /^\d+$/
@@ -57,16 +61,28 @@ class App
57
61
  c.default_value 'na'
58
62
  c.flag %i[t tag]
59
63
 
60
- c.action do |global_options, options, _|
64
+ c.action do |global_options, options, args|
61
65
  if global_options[:add]
62
66
  cmd = ['add']
63
67
  cmd.push('--note') if global_options[:note]
64
68
  cmd.concat(['--priority', global_options[:priority]]) if global_options[:priority]
65
- cmd.push(ARGV.unshift(@command))
66
- p cmd
69
+ cmd.push(ARGV.unshift($first_arg)) if ARGV.count.positive?
70
+
67
71
  exit run(cmd)
68
72
  end
69
73
 
74
+
75
+ if args.count.positive?
76
+ tokens = []
77
+ args.each do |arg|
78
+ m = arg.match(/^(?<req>\+)?(?<tok>.*?)$/)
79
+ tokens.push({
80
+ token: m['tok'],
81
+ required: !m['req'].nil?
82
+ })
83
+ end
84
+ end
85
+
70
86
  depth = if global_options[:recurse] && options[:depth].nil? && global_options[:depth] == 1
71
87
  3
72
88
  else
@@ -74,16 +90,27 @@ class App
74
90
  end
75
91
  tag = options[:tag] == global_options[:na_tag] ? nil : options[:tag]
76
92
  actions = NA.parse_actions(depth: depth,
93
+ query: tokens,
77
94
  extension: global_options[:ext],
78
95
  na_tag: global_options[:na_tag],
79
96
  tag: tag)
97
+
80
98
  NA.output_actions(actions, depth, global_options[:ext])
81
99
  end
82
100
  end
83
101
 
84
102
  desc 'Add a new next action'
103
+ long_desc 'Provides an easy way to store todos while you work. Add quick reminders and (if you set up Prompt Hooks)
104
+ they\'ll automatically display next time you enter the directory.
105
+
106
+ If multiple todo files are found in the current directory, a menu will allow you to pick to which
107
+ file the action gets added.'
85
108
  arg_name 'TASK'
86
109
  command :add do |c|
110
+ c.example 'na add "A cool feature I thought of @idea"', desc: 'Add a new action to the Inbox, including a tag'
111
+ c.example 'na add "A bug I need to fix" -p 4 -n',
112
+ desc: 'Add a new action to the Inbox, set its @priority to 4, and prompt for an additional note'
113
+
87
114
  c.desc 'Prompt for additional notes'
88
115
  c.switch %i[n note]
89
116
 
@@ -103,7 +130,7 @@ class App
103
130
  action = if args.count.positive?
104
131
  args.join(' ').strip
105
132
  elsif TTY::Which.exist?('gum')
106
- `gum input --placeholder "Enter a task"`.strip
133
+ `gum input --placeholder "Enter a task" --char-limit=500 --width=#{TTY::Screen.columns}`.strip
107
134
  else
108
135
  puts NA::Color.template('{bm}Enter task:{x}')
109
136
  reader.read_line(NA::Color.template('{by}> {bw}')).strip
@@ -163,6 +190,7 @@ class App
163
190
  end
164
191
  end
165
192
 
193
+ NA.save_working_dir(File.expand_path(target))
166
194
  NA.add_action(target, action, note)
167
195
  end
168
196
  end
@@ -172,6 +200,10 @@ class App
172
200
  (partial matches allowed). Add a + before a token to make it required, e.g. `na find +feature +maybe`'
173
201
  arg_name 'PATTERN'
174
202
  command %i[find] do |c|
203
+ c.example 'na find feature +idea +swift', desc: 'Find all actions containing feature, idea, and swift'
204
+ c.example 'na find -x feature idea', desc: 'Find all actions containing the exact text "feature idea"'
205
+ c.example 'na find -d 3 swift obj-c', desc: 'Find all actions 3 directories deep containing either swift or obj-c'
206
+
175
207
  c.desc 'Match pattern exactly'
176
208
  c.switch %i[x exact]
177
209
 
@@ -215,6 +247,9 @@ class App
215
247
  e.g. `na tagged feature +maybe`'
216
248
  arg_name 'TAG [VALUE]'
217
249
  command %i[tagged] do |c|
250
+ c.example 'na tagged +maybe', desc: 'Show all actions tagged @maybe'
251
+ c.example 'na tagged -d 3 feature idea', desc: 'Show all actions tagged either @feature or @idea, recurse 3 levels'
252
+
218
253
  c.desc 'Recurse to depth'
219
254
  c.arg_name 'DEPTH'
220
255
  c.default_value 1
@@ -269,7 +304,7 @@ class App
269
304
  if ARGV.count.positive?
270
305
  cmd.concat(ARGV.unshift($first_arg))
271
306
  end
272
- p cmd
307
+
273
308
  exit run(cmd)
274
309
  when SystemExit
275
310
  false
@@ -83,7 +83,7 @@ module NA
83
83
  puts actions.map { |action| action.pretty(template: { output: template }) }
84
84
  end
85
85
 
86
- def parse_actions(depth: 1, extension: 'taskpaper', na_tag: 'na', tag: nil, search: nil)
86
+ def parse_actions(depth: 1, extension: 'taskpaper', na_tag: 'na', query: nil, tag: nil, search: nil)
87
87
  actions = []
88
88
  required = []
89
89
  optional = []
@@ -112,8 +112,14 @@ module NA
112
112
 
113
113
  na_tag = "@#{na_tag.sub(/^@/, '')}"
114
114
 
115
- files = find_files(depth: depth, extension: extension)
115
+ if query.nil?
116
+ files = find_files(depth: depth, extension: extension)
117
+ else
118
+ files = match_working_dir(query)
119
+ end
120
+
116
121
  files.each do |file|
122
+ save_working_dir(File.expand_path(file))
117
123
  content = IO.read(file)
118
124
  indent_level = 0
119
125
  parent = []
@@ -177,5 +183,52 @@ module NA
177
183
 
178
184
  res
179
185
  end
186
+
187
+ def match_working_dir(search)
188
+ optional = []
189
+ required = []
190
+
191
+ search&.each do |t|
192
+ new_rx = t[:token].to_s
193
+
194
+ optional.push(new_rx)
195
+ required.push(new_rx) if t[:required]
196
+ end
197
+
198
+ db_dir = File.expand_path('~/.local/share/na')
199
+ db_file = 'tdlist.txt'
200
+ file = File.join(db_dir, db_file)
201
+ if File.exist?(file)
202
+ dirs = IO.read(file).split("\n")
203
+ dirs.delete_if { |d| !d.matches(any: optional, all: required) }
204
+ dirs.sort.uniq
205
+ else
206
+ puts NA::Color.template('{r}No na database found{x}')
207
+ Process.exit 1
208
+ end
209
+ end
210
+
211
+ def save_working_dir(todo_file)
212
+ db_dir = File.expand_path('~/.local/share/na')
213
+ FileUtils.mkdir_p(db_dir) unless File.directory?(db_dir)
214
+ db_file = 'tdlist.txt'
215
+ file = File.join(db_dir, db_file)
216
+ content = File.exist?(file) ? IO.read(file) : ''
217
+ dirs = content.split(/\n/)
218
+ dirs.push(File.expand_path(todo_file))
219
+ dirs.sort!.uniq!
220
+ File.open(file, 'w') { |f| f.puts dirs.join("\n") }
221
+ end
222
+
223
+ def weed_cache_file
224
+ db_dir = File.expand_path('~/.local/share/na')
225
+ db_file = 'tdlist.txt'
226
+ file = File.join(db_dir, db_file)
227
+ if File.exist?(file)
228
+ dirs = IO.read(file).split("\n")
229
+ dirs.delete_if { |f| !File.exist?(f) }
230
+ File.open(file, 'w') { |f| f.puts dirs.join("\n") }
231
+ end
232
+ end
180
233
  end
181
234
  end
data/lib/na/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Na
2
- VERSION = '1.0.0'
2
+ VERSION = '1.0.2'
3
3
  end
data/lib/na.rb CHANGED
@@ -2,7 +2,9 @@ require 'na/version.rb'
2
2
 
3
3
  # Add requires for other files you add to your project here, so
4
4
  # you just need to require this one file in your bin file
5
+ require 'fileutils'
5
6
  require 'shellwords'
7
+ require 'tty-screen'
6
8
  require 'tty-reader'
7
9
  require 'tty-which'
8
10
  require 'na/colors.rb'
data/na.gemspec CHANGED
@@ -5,22 +5,29 @@ spec = Gem::Specification.new do |s|
5
5
  s.version = Na::VERSION
6
6
  s.author = 'Brett Terpstra'
7
7
  s.email = 'me@brettterpstra.com'
8
- s.homepage = 'https://brettterpstra.com'
8
+ s.homepage = 'https://brettterpstra.com/projects/na/'
9
9
  s.platform = Gem::Platform::RUBY
10
10
  s.summary = 'A command line tool for adding and listing project todos'
11
+ s.description = [
12
+ 'A tool for managing a TaskPaper file of project todos for the current directory.',
13
+ 'Easily create "next actions" to come back to, add tags and priorities, and notes.',
14
+ 'Add prompt hooks to display your next actions automatically when cd\'ing into a directory.'
15
+ ].join(' ')
11
16
  s.license = 'MIT'
12
17
  s.files = Dir.chdir(File.expand_path('..', __FILE__)) do
13
18
  `git ls-files -z`.split("\x0").reject { |f| f.strip =~ %r{^((test|spec|features)/|\.git|buildnotes|.*\.taskpaper)} }
14
19
  end
15
20
  s.require_paths << 'lib'
16
- s.extra_rdoc_files = ['README.rdoc','na.rdoc']
17
- s.rdoc_options << '--title' << 'na' << '--main' << 'README.rdoc' << '-ri'
21
+ s.extra_rdoc_files = ['README.md','na.rdoc']
22
+ s.rdoc_options << '--title' << 'na' << '--main' << 'README.md' << '--markup' << 'markdown'
18
23
  s.bindir = 'bin'
19
24
  s.executables << 'na'
20
25
  s.add_development_dependency('rake','~> 0.9.2')
21
26
  s.add_development_dependency('rdoc', '~> 4.3')
22
27
  s.add_development_dependency('minitest', '~> 5.14')
28
+ s.add_development_dependency('yard', '~> 0.9', '>= 0.9.26')
23
29
  s.add_runtime_dependency('gli','~> 2.21.0')
24
30
  s.add_runtime_dependency('tty-reader', '~> 0.9', '>= 0.9.0')
31
+ s.add_runtime_dependency('tty-screen', '~> 0.8', '>= 0.8.1')
25
32
  s.add_runtime_dependency('tty-which', '~> 0.5', '>= 0.5.0')
26
33
  end