na 1.0.0 → 1.0.1

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: 2d4f45d14fddff26b88853edcac42f9d8250de1848f5d639138d757a0ce5bfe1
4
- data.tar.gz: 73057d29cf56b1a3069973f5ea1ab4c06c4fcf76778997df12e51a56baf6ca0f
3
+ metadata.gz: 4841ea0f17ec2751c09ae7277fa773dd0730a9055eaae68389f4651b606f5fc6
4
+ data.tar.gz: 3d056faf540401934754cac051bd29f75c8c851607731d5f16bd937baa8e0968
5
5
  SHA512:
6
- metadata.gz: 1cfcd9dcf3543954f558ac25438bf84384f7c41fdde3f20ec7b6ce8970f971841e940d84b5eb003c5aa26dd17b77fde85901c10b9c30cb179a39a7ea1e26ac07
7
- data.tar.gz: 824e2b356c805301fefd096bc851979e307268bb3ddc4f581c74cf03a4b8cf17de688e329a039c8754f646af99e6944f217d4cdd2e02a676fe7763ed08e93a26
6
+ metadata.gz: 612464ec3687922763b9469a65f32b6773dfdc1a98f965f8c3b2f16ba3709c7972fe4771f6c68e5bff3506d329e9e39c4fe1f3bb2257aa2b09dbe06f0389cb85
7
+ data.tar.gz: 4e770547abaa252ef7f5b4a691476b1f6c48eb8d9d6304bbf408c12d741ea606d70f7d5331dc8943f445a25622127358fbd96fd03c12bfbaec0384ba4e841943
data/CHANGELOG.md CHANGED
@@ -5,4 +5,3 @@
5
5
  #### IMPROVED
6
6
 
7
7
  - Backwards compatibility with the Bash version of NA
8
-
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- na (1.0.0)
4
+ na (1.0.1)
5
5
  gli (~> 2.21.0)
6
6
  tty-reader (~> 0.9, >= 0.9.0)
7
7
  tty-which (~> 0.5, >= 0.5.0)
@@ -20,7 +20,10 @@ GEM
20
20
  wisper (~> 2.0)
21
21
  tty-screen (0.8.1)
22
22
  tty-which (0.5.0)
23
+ webrick (1.7.0)
23
24
  wisper (2.0.1)
25
+ yard (0.9.28)
26
+ webrick (~> 1.7.0)
24
27
 
25
28
  PLATFORMS
26
29
  arm64-darwin-20
@@ -30,6 +33,7 @@ DEPENDENCIES
30
33
  na!
31
34
  rake (~> 0.9.2)
32
35
  rdoc (~> 4.3)
36
+ yard (~> 0.9, >= 0.9.26)
33
37
 
34
38
  BUNDLED WITH
35
39
  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,217 @@
1
+ # na
2
+
3
+ [![Gem](https://img.shields.io/gem/v/doing.svg)](https://rubygems.org/gems/na)
4
+ [![Travis](https://app.travis-ci.com/ttscoff/doing.svg?branch=master)](https://travis-ci.org/makenew/na_gem)
5
+ [![GitHub license](https://img.shields.io/github/license/ttscoff/doing.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
+ <!--README-->
13
+
14
+ The current version of `na` is <!--VER-->1.0.0<!--END VER-->.
15
+
16
+ `na` 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.
17
+
18
+ Used with Taskpaper files, it can add new todo items quickly from the command line, automatically tagging them as next actions.
19
+
20
+ 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.
21
+
22
+ ### Features
23
+
24
+ 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.
25
+
26
+ #### Easy matching
27
+
28
+ `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.
29
+
30
+ #### Recursion
31
+
32
+ `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.
33
+
34
+ #### Adding todos
35
+
36
+ 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).
37
+
38
+ 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.
39
+
40
+ ### Installation
41
+
42
+ Just run `gem install na`. If you run into errors, use `sudo gem install na`.
43
+
44
+ ### Usage
45
+
46
+ ```
47
+ GLOBAL OPTIONS
48
+ -a, --[no-]add - Add a next action (deprecated, for backwards compatibility)
49
+ -d, --depth=DEPTH - Recurse to depth (default: 1)
50
+ --ext=FILE_EXTENSION - File extension to consider a todo file (default: taskpaper)
51
+ --help - Show this message
52
+ -n, --[no-]note - Prompt for additional notes (deprecated, for backwards compatibility)
53
+ --na_tag=TAG - Tag to consider a next action (default: na)
54
+ -p, --priority=PRIORITY - Set a priority 0-5 (deprecated, for backwards compatibility) (default: none)
55
+ -r, --[no-]recurse - Recurse 3 directories deep (deprecated, for backwards compatability)
56
+ --version - Display the program version
57
+
58
+
59
+
60
+ COMMANDS
61
+ add - Add a new next action
62
+ find - Find actions matching a search pattern
63
+ help - Shows a list of commands or help for one command
64
+ initconfig - Initialize the config file using current global options
65
+ next, show - Show next actions
66
+ tagged - Find actions matching a tag
67
+ ```
68
+
69
+ #### Commands
70
+
71
+ ##### add
72
+
73
+ Example: `na add This feature @idea I have`
74
+
75
+ ```
76
+ NAME
77
+ add - Add a new next action
78
+
79
+ SYNOPSIS
80
+
81
+ na [global options] add [command options] TASK
82
+
83
+
84
+ COMMAND OPTIONS
85
+ -f, --file=PATH - Specify the file to which the task should be added (default: none)
86
+ -n, --[no-]note - Prompt for additional notes
87
+ -p, --priority=arg - Add a priority level 1-5 (default: 0)
88
+ -t, --tag=TAG - Use a tag other than the default next action tag (default: none)
89
+ ```
90
+
91
+ ##### find
92
+
93
+ Example: `na find cool feature idea`
94
+
95
+ ```
96
+ NAME
97
+ find - Find actions matching a search pattern
98
+
99
+ SYNOPSIS
100
+
101
+ na [global options] find [command options] PATTERN
102
+
103
+
104
+
105
+ DESCRIPTION
106
+ Search tokens are separated by spaces. Actions matching any token in the pattern will be shown (partial matches allowed). Add a +
107
+ before a token to make it required, e.g. `na find +feature +maybe`
108
+
109
+
110
+
111
+ COMMAND OPTIONS
112
+ -d, --depth=DEPTH - Recurse to depth (default: 1)
113
+ -x, --[no-]exact - Match pattern exactly
114
+ ```
115
+
116
+ ##### next, show
117
+
118
+ Examples:
119
+
120
+ - `na show` (list all next actions in the current directory)
121
+ - `na show -d 3` (list all next actions in the current directory and look for additional files 3 levels deep from there)
122
+ - `na show marked2` (show next actions from another directory you've previously used na on)
123
+
124
+ ```
125
+ NAME
126
+ next - Show next actions
127
+
128
+ SYNOPSIS
129
+
130
+ na [global options] next [command options] OPTIONAL_QUERY
131
+
132
+
133
+ COMMAND OPTIONS
134
+ -d, --depth=DEPTH - Recurse to depth (default: none)
135
+ -t, --tag=arg - Alternate tag to search for (default: na)
136
+ ```
137
+
138
+ ##### tagged
139
+
140
+ Example: `na tagged feature +maybe`
141
+
142
+ ```
143
+ NAME
144
+ tagged - Find actions matching a tag
145
+
146
+ SYNOPSIS
147
+
148
+ na [global options] tagged [command options] TAG [VALUE]
149
+
150
+
151
+
152
+ DESCRIPTION
153
+ 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
154
+ make it required, e.g. `na tagged feature +maybe`
155
+
156
+
157
+
158
+ COMMAND OPTIONS
159
+ -d, --depth=DEPTH - Recurse to depth (default: 1)
160
+ ```
161
+
162
+ ### Configuration
163
+
164
+ 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.
165
+
166
+ Example: `na --ext md --na_tag next initconfig --force`
167
+
168
+ ### Prompt Hooks
169
+
170
+ 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:
171
+
172
+ _(You can add `-r` to any of these calls to na to automatically recurse 3 directories deep)_
173
+
174
+ Bash (in ~/.bash_profile):
175
+
176
+ ```bash
177
+ last_command_was_cd() {
178
+ [[ $(history 1|sed -e "s/^[ ]*[0-9]*[ ]*//") =~ ^((cd|z|j|jump|g|f|pushd|popd|exit)([ ]|$)) ]] && na
179
+ }
180
+ if [[ -z "$PROMPT_COMMAND" ]]; then
181
+ PROMPT_COMMAND="eval 'last_command_was_cd'"
182
+ else
183
+ echo $PROMPT_COMMAND | grep -v -q "last_command_was_cd" && PROMPT_COMMAND="$PROMPT_COMMAND;"'eval "last_command_was_cd"'
184
+ fi
185
+ ```
186
+
187
+ Fish (in ~/.config/fish/conf.d/*.fish):
188
+
189
+ ```fish
190
+ function __should_na --on-variable PWD
191
+ # function __should_na --on-event fish_prompt
192
+ test -s (basename $PWD)".taskpaper" && na
193
+ end
194
+ ```
195
+
196
+ Zsh (in ~/.zshrc):
197
+
198
+ ```zsh
199
+ chpwd() { na }
200
+ ```
201
+
202
+
203
+ ### Misc
204
+
205
+ If you have [gum][] installed, na will use it for command line input when adding tasks and notes.
206
+
207
+ [gum]: https://github.com/charmbracelet/gum
208
+ [donate]: http://brettterpstra.com/donate/
209
+ [github]: https://github.com/ttscoff/na_gem/
210
+
211
+ <!--END README-->
212
+
213
+ PayPal link: [paypal.me/ttscoff](https://paypal.me/ttscoff)
214
+
215
+ ## Changelog
216
+
217
+ See [CHANGELOG.md](https://github.com/ttscoff/na_gem/blob/master/CHANGELOG.md)
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,6 +48,7 @@ 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|
52
53
  c.desc 'Recurse to depth'
53
54
  c.arg_name 'DEPTH'
@@ -57,7 +58,7 @@ class App
57
58
  c.default_value 'na'
58
59
  c.flag %i[t tag]
59
60
 
60
- c.action do |global_options, options, _|
61
+ c.action do |global_options, options, args|
61
62
  if global_options[:add]
62
63
  cmd = ['add']
63
64
  cmd.push('--note') if global_options[:note]
@@ -67,6 +68,18 @@ class App
67
68
  exit run(cmd)
68
69
  end
69
70
 
71
+
72
+ if args.count.positive?
73
+ tokens = []
74
+ args.each do |arg|
75
+ m = arg.match(/^(?<req>\+)?(?<tok>.*?)$/)
76
+ tokens.push({
77
+ token: m['tok'],
78
+ required: !m['req'].nil?
79
+ })
80
+ end
81
+ end
82
+
70
83
  depth = if global_options[:recurse] && options[:depth].nil? && global_options[:depth] == 1
71
84
  3
72
85
  else
@@ -74,9 +87,11 @@ class App
74
87
  end
75
88
  tag = options[:tag] == global_options[:na_tag] ? nil : options[:tag]
76
89
  actions = NA.parse_actions(depth: depth,
90
+ query: tokens,
77
91
  extension: global_options[:ext],
78
92
  na_tag: global_options[:na_tag],
79
93
  tag: tag)
94
+
80
95
  NA.output_actions(actions, depth, global_options[:ext])
81
96
  end
82
97
  end
@@ -163,6 +178,7 @@ class App
163
178
  end
164
179
  end
165
180
 
181
+ save_working_dir(File.expand_path(target))
166
182
  NA.add_action(target, action, note)
167
183
  end
168
184
  end
data/html/created.rid CHANGED
@@ -1,9 +1,9 @@
1
- Tue, 27 Sep 2022 10:51:50 -0500
1
+ Tue, 27 Sep 2022 12:40:56 -0500
2
2
  README.rdoc Tue, 27 Sep 2022 10:44:08 -0500
3
- lib/na.rb Tue, 27 Sep 2022 05:21:27 -0500
3
+ lib/na.rb Tue, 27 Sep 2022 11:36:48 -0500
4
4
  lib/na/action.rb Tue, 27 Sep 2022 09:38:32 -0500
5
5
  lib/na/colors.rb Tue, 27 Sep 2022 03:25:39 -0500
6
- lib/na/next_action.rb Tue, 27 Sep 2022 10:13:13 -0500
6
+ lib/na/next_action.rb Tue, 27 Sep 2022 12:05:46 -0500
7
7
  lib/na/string.rb Tue, 27 Sep 2022 09:37:41 -0500
8
- lib/na/version.rb Tue, 27 Sep 2022 07:26:43 -0500
9
- bin/na Tue, 27 Sep 2022 10:42:39 -0500
8
+ lib/na/version.rb Tue, 27 Sep 2022 11:33:15 -0500
9
+ bin/na Tue, 27 Sep 2022 12:06:13 -0500
@@ -1 +1 @@
1
- var search_data = {"index":{"searchIndex":["app","na","action","color","na","string","add_action()","attributes()","choose_from()","coloring()","coloring?()","create_todo()","find_files()","highlight_tags()","indent_level()","inspect()","last_color_code()","matches()","matches_all()","matches_any()","new()","normalize_color()","output_actions()","parse_actions()","pretty()","rgb()","select_file()","support?()","template()","to_s()","uncolor()","validate_color()","readme"],"longSearchIndex":["app","na","na::action","na::color","na","string","na::add_action()","na::color#attributes()","na::choose_from()","na::color::coloring()","na::color::coloring?()","na::create_todo()","na::find_files()","string#highlight_tags()","string#indent_level()","na::action#inspect()","string#last_color_code()","string#matches()","string#matches_all()","string#matches_any()","na::action::new()","string#normalize_color()","na::output_actions()","na::parse_actions()","na::action#pretty()","na::color#rgb()","na::select_file()","na::color#support?()","na::color::template()","na::action#to_s()","na::color#uncolor()","string#validate_color()",""],"info":[["App","","App.html","",""],["NA","","NA.html","","<p>Cribbed from &lt;github.com/flori/term-ansicolor&gt;\n<p>Next Action methods\n"],["NA::Action","","NA/Action.html","",""],["NA::Color","","NA/Color.html","","<p>Terminal output color functions.\n"],["Na","","Na.html","",""],["String","","String.html","","<p>Template coloring\n"],["add_action","NA","NA.html#method-c-add_action","(file, action, note = nil)",""],["attributes","NA::Color","NA/Color.html#method-i-attributes","()","<p>Returns an array of all NA::Color attributes as symbols.\n"],["choose_from","NA","NA.html#method-c-choose_from","(options, prompt: 'Make a selection: ', multiple: false, sorted: true, fzf_args: [])","<p>Generate a menu of options and allow user selection\n<p>@return [String] The selected option\n<p>@param …\n"],["coloring","NA::Color","NA/Color.html#method-c-coloring","()","<p>Enables colored output\n<p>@example Turn color on or off based on TTY\n\n<pre class=\"ruby\"><span class=\"ruby-constant\">NA</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Color</span>.<span class=\"ruby-identifier\">coloring</span> = <span class=\"ruby-constant\">STDOUT</span>.<span class=\"ruby-identifier\">isatty</span>\n</pre>\n"],["coloring?","NA::Color","NA/Color.html#method-c-coloring-3F","()","<p>Returns true if the coloring function of this module is switched on, false otherwise.\n"],["create_todo","NA","NA.html#method-c-create_todo","(target, basename)",""],["find_files","NA","NA.html#method-c-find_files","(depth: 1, extension: 'taskpaper')",""],["highlight_tags","String","String.html#method-i-highlight_tags","(color: '{m}', value: '{y}', parens: '{m}', last_color: '{g}')","<p>Colorize @tags with ANSI escapes\n<p>@param color [String] color (see #Color)\n<p>@return [String] string …\n"],["indent_level","String","String.html#method-i-indent_level","()",""],["inspect","NA::Action","NA/Action.html#method-i-inspect","()",""],["last_color_code","String","String.html#method-i-last_color_code","()","<p>Get the calculated ANSI color at the end of the string\n<p>@return ANSI escape sequence to match color …\n"],["matches","String","String.html#method-i-matches","(any: [], all: [])",""],["matches_all","String","String.html#method-i-matches_all","(regexes)",""],["matches_any","String","String.html#method-i-matches_any","(regexes)",""],["new","NA::Action","NA/Action.html#method-c-new","(file, project, parent, action)",""],["normalize_color","String","String.html#method-i-normalize_color","()","<p>Normalize a color name, removing underscores, replacing “bright” with “bold”, and …\n"],["output_actions","NA","NA.html#method-c-output_actions","(actions, depth, extension)",""],["parse_actions","NA","NA.html#method-c-parse_actions","(depth: 1, extension: 'taskpaper', na_tag: 'na', tag: nil, search: nil)",""],["pretty","NA::Action","NA/Action.html#method-i-pretty","(extension: 'taskpaper', template: {})",""],["rgb","NA::Color","NA/Color.html#method-i-rgb","(hex)","<p>Generate escape codes for hex colors\n<p>@param hex [String] The hexadecimal color code\n<p>@return …\n"],["select_file","NA","NA.html#method-c-select_file","(files)",""],["support?","NA::Color","NA/Color.html#method-i-support-3F","(feature)","<p>Returns true if NA::Color supports the <code>feature</code>.\n<p>The feature :clear, that is mixing the clear color attribute …\n"],["template","NA::Color","NA/Color.html#method-c-template","(input)","<p>Convert a template string to a colored string. Colors are specified with single letters inside curly …\n"],["to_s","NA::Action","NA/Action.html#method-i-to_s","()",""],["uncolor","NA::Color","NA/Color.html#method-i-uncolor","(string = nil)","<p>Returns an uncolored version of the string, that is all ANSI-sequences are stripped from the string. …\n"],["validate_color","String","String.html#method-i-validate_color","()","<p>Extract the longest valid %color name from a string.\n<p>Allows %colors to bleed into other text and still …\n"],["README","","README_rdoc.html","","<p>na\n<p>A command line tool for adding and listing project todos in TaskPaper format.\n<p>na - Add and list next …\n"]]}}
1
+ var search_data = {"index":{"searchIndex":["app","na","action","color","na","string","add_action()","attributes()","choose_from()","coloring()","coloring?()","create_todo()","find_files()","highlight_tags()","indent_level()","inspect()","last_color_code()","match_working_dir()","matches()","matches_all()","matches_any()","new()","normalize_color()","output_actions()","parse_actions()","pretty()","rgb()","save_working_dir()","select_file()","support?()","template()","to_s()","uncolor()","validate_color()","weed_cache_file()","readme"],"longSearchIndex":["app","na","na::action","na::color","na","string","na::add_action()","na::color#attributes()","na::choose_from()","na::color::coloring()","na::color::coloring?()","na::create_todo()","na::find_files()","string#highlight_tags()","string#indent_level()","na::action#inspect()","string#last_color_code()","na::match_working_dir()","string#matches()","string#matches_all()","string#matches_any()","na::action::new()","string#normalize_color()","na::output_actions()","na::parse_actions()","na::action#pretty()","na::color#rgb()","na::save_working_dir()","na::select_file()","na::color#support?()","na::color::template()","na::action#to_s()","na::color#uncolor()","string#validate_color()","na::weed_cache_file()",""],"info":[["App","","App.html","",""],["NA","","NA.html","","<p>Cribbed from &lt;github.com/flori/term-ansicolor&gt;\n<p>Next Action methods\n"],["NA::Action","","NA/Action.html","",""],["NA::Color","","NA/Color.html","","<p>Terminal output color functions.\n"],["Na","","Na.html","",""],["String","","String.html","","<p>Template coloring\n"],["add_action","NA","NA.html#method-c-add_action","(file, action, note = nil)",""],["attributes","NA::Color","NA/Color.html#method-i-attributes","()","<p>Returns an array of all NA::Color attributes as symbols.\n"],["choose_from","NA","NA.html#method-c-choose_from","(options, prompt: 'Make a selection: ', multiple: false, sorted: true, fzf_args: [])","<p>Generate a menu of options and allow user selection\n<p>@return [String] The selected option\n<p>@param …\n"],["coloring","NA::Color","NA/Color.html#method-c-coloring","()","<p>Enables colored output\n<p>@example Turn color on or off based on TTY\n\n<pre class=\"ruby\"><span class=\"ruby-constant\">NA</span><span class=\"ruby-operator\">::</span><span class=\"ruby-constant\">Color</span>.<span class=\"ruby-identifier\">coloring</span> = <span class=\"ruby-constant\">STDOUT</span>.<span class=\"ruby-identifier\">isatty</span>\n</pre>\n"],["coloring?","NA::Color","NA/Color.html#method-c-coloring-3F","()","<p>Returns true if the coloring function of this module is switched on, false otherwise.\n"],["create_todo","NA","NA.html#method-c-create_todo","(target, basename)",""],["find_files","NA","NA.html#method-c-find_files","(depth: 1, extension: 'taskpaper')",""],["highlight_tags","String","String.html#method-i-highlight_tags","(color: '{m}', value: '{y}', parens: '{m}', last_color: '{g}')","<p>Colorize @tags with ANSI escapes\n<p>@param color [String] color (see #Color)\n<p>@return [String] string …\n"],["indent_level","String","String.html#method-i-indent_level","()",""],["inspect","NA::Action","NA/Action.html#method-i-inspect","()",""],["last_color_code","String","String.html#method-i-last_color_code","()","<p>Get the calculated ANSI color at the end of the string\n<p>@return ANSI escape sequence to match color …\n"],["match_working_dir","NA","NA.html#method-c-match_working_dir","(search)",""],["matches","String","String.html#method-i-matches","(any: [], all: [])",""],["matches_all","String","String.html#method-i-matches_all","(regexes)",""],["matches_any","String","String.html#method-i-matches_any","(regexes)",""],["new","NA::Action","NA/Action.html#method-c-new","(file, project, parent, action)",""],["normalize_color","String","String.html#method-i-normalize_color","()","<p>Normalize a color name, removing underscores, replacing “bright” with “bold”, and …\n"],["output_actions","NA","NA.html#method-c-output_actions","(actions, depth, extension)",""],["parse_actions","NA","NA.html#method-c-parse_actions","(depth: 1, extension: 'taskpaper', na_tag: 'na', query: nil, tag: nil, search: nil)",""],["pretty","NA::Action","NA/Action.html#method-i-pretty","(extension: 'taskpaper', template: {})",""],["rgb","NA::Color","NA/Color.html#method-i-rgb","(hex)","<p>Generate escape codes for hex colors\n<p>@param hex [String] The hexadecimal color code\n<p>@return …\n"],["save_working_dir","NA","NA.html#method-c-save_working_dir","(todo_file)",""],["select_file","NA","NA.html#method-c-select_file","(files)",""],["support?","NA::Color","NA/Color.html#method-i-support-3F","(feature)","<p>Returns true if NA::Color supports the <code>feature</code>.\n<p>The feature :clear, that is mixing the clear color attribute …\n"],["template","NA::Color","NA/Color.html#method-c-template","(input)","<p>Convert a template string to a colored string. Colors are specified with single letters inside curly …\n"],["to_s","NA::Action","NA/Action.html#method-i-to_s","()",""],["uncolor","NA::Color","NA/Color.html#method-i-uncolor","(string = nil)","<p>Returns an uncolored version of the string, that is all ANSI-sequences are stripped from the string. …\n"],["validate_color","String","String.html#method-i-validate_color","()","<p>Extract the longest valid %color name from a string.\n<p>Allows %colors to bleed into other text and still …\n"],["weed_cache_file","NA","NA.html#method-c-weed_cache_file","()",""],["README","","README_rdoc.html","","<p>na\n<p>A command line tool for adding and listing project todos in TaskPaper format.\n<p>na - Add and list next …\n"]]}}
Binary file
@@ -126,6 +126,11 @@
126
126
  &mdash;
127
127
  <span class="container">NA</span>
128
128
 
129
+ <li class="method">
130
+ <a href="NA.html#method-c-match_working_dir">::match_working_dir</a>
131
+ &mdash;
132
+ <span class="container">NA</span>
133
+
129
134
  <li class="method">
130
135
  <a href="NA/Action.html#method-c-new">::new</a>
131
136
  &mdash;
@@ -141,6 +146,11 @@
141
146
  &mdash;
142
147
  <span class="container">NA</span>
143
148
 
149
+ <li class="method">
150
+ <a href="NA.html#method-c-save_working_dir">::save_working_dir</a>
151
+ &mdash;
152
+ <span class="container">NA</span>
153
+
144
154
  <li class="method">
145
155
  <a href="NA.html#method-c-select_file">::select_file</a>
146
156
  &mdash;
@@ -151,6 +161,11 @@
151
161
  &mdash;
152
162
  <span class="container">NA::Color</span>
153
163
 
164
+ <li class="method">
165
+ <a href="NA.html#method-c-weed_cache_file">::weed_cache_file</a>
166
+ &mdash;
167
+ <span class="container">NA</span>
168
+
154
169
  <li class="method">
155
170
  <a href="NA/Color.html#method-i-attributes">#attributes</a>
156
171
  &mdash;
@@ -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.1'
3
3
  end
data/lib/na.rb CHANGED
@@ -2,6 +2,7 @@ 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'
6
7
  require 'tty-reader'
7
8
  require 'tty-which'
data/na.gemspec CHANGED
@@ -20,6 +20,7 @@ spec = Gem::Specification.new do |s|
20
20
  s.add_development_dependency('rake','~> 0.9.2')
21
21
  s.add_development_dependency('rdoc', '~> 4.3')
22
22
  s.add_development_dependency('minitest', '~> 5.14')
23
+ s.add_development_dependency('yard', '~> 0.9', '>= 0.9.26')
23
24
  s.add_runtime_dependency('gli','~> 2.21.0')
24
25
  s.add_runtime_dependency('tty-reader', '~> 0.9', '>= 0.9.0')
25
26
  s.add_runtime_dependency('tty-which', '~> 0.5', '>= 0.5.0')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: na
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brett Terpstra
@@ -52,6 +52,26 @@ dependencies:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5.14'
55
+ - !ruby/object:Gem::Dependency
56
+ name: yard
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.9'
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: 0.9.26
65
+ type: :development
66
+ prerelease: false
67
+ version_requirements: !ruby/object:Gem::Requirement
68
+ requirements:
69
+ - - "~>"
70
+ - !ruby/object:Gem::Version
71
+ version: '0.9'
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 0.9.26
55
75
  - !ruby/object:Gem::Dependency
56
76
  name: gli
57
77
  requirement: !ruby/object:Gem::Requirement
@@ -118,6 +138,8 @@ files:
118
138
  - CHANGELOG.md
119
139
  - Gemfile
120
140
  - Gemfile.lock
141
+ - LICENSE.txt
142
+ - README.md
121
143
  - README.rdoc
122
144
  - Rakefile
123
145
  - bin/na