na 1.2.53 → 1.2.54
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +1 -1
- data/README.md +6 -3
- data/Test.todo.markdown +25 -13
- data/bin/commands/tag.rb +0 -4
- data/bin/commands/undo.rb +10 -1
- data/bin/na +1 -0
- data/lib/na/array.rb +2 -0
- data/lib/na/next_action.rb +57 -10
- data/lib/na/string.rb +3 -1
- data/lib/na/version.rb +1 -1
- data/src/_README.md +1 -1
- data/test2.txt +7 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3d67defa193fd36e28d744d1b42a56ef6815db6b4994b07a5d7fa4af447ca14c
|
4
|
+
data.tar.gz: cf5e9a3e396ad102e0b15481873affcea80d1bb0a7571136992957d920de5db7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38fbd19efd1897a91c1a0c0440a390748a8e51ab481c9b2b41b0011644623f9b091be8b26ff23afdeb8f990b42e2ba924c6df4634eb6fec4aa17a9c60fd40b6e
|
7
|
+
data.tar.gz: 79b7d7b7f016d5307fc7604ddafebea525a3c4ce5f3fa7a923921b2502dec4ba697dc8f4c59cab4df9d2ed90b487a3566e230d9f2d6cb258881a1ff16fab7f31
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,12 @@
|
|
1
|
+
### 1.2.54
|
2
|
+
|
3
|
+
2023-09-11 10:11
|
4
|
+
|
5
|
+
#### IMPROVED
|
6
|
+
|
7
|
+
- Allow selection of action if no search text is provided for tag command
|
8
|
+
- If the terminal is less than 60 columns wide, don't indent or wrap (for display on mobile devices)
|
9
|
+
|
1
10
|
### 1.2.53
|
2
11
|
|
3
12
|
2023-09-10 08:26
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
_If you're one of the rare people like me who find this useful, feel free to
|
10
10
|
[buy me some coffee][donate]._
|
11
11
|
|
12
|
-
The current version of `na` is 1.2.
|
12
|
+
The current version of `na` is 1.2.54
|
13
13
|
.
|
14
14
|
|
15
15
|
`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.
|
@@ -77,7 +77,7 @@ SYNOPSIS
|
|
77
77
|
na [global options] command [command options] [arguments...]
|
78
78
|
|
79
79
|
VERSION
|
80
|
-
1.2.
|
80
|
+
1.2.54
|
81
81
|
|
82
82
|
GLOBAL OPTIONS
|
83
83
|
-a, --add - Add a next action (deprecated, for backwards compatibility)
|
@@ -660,11 +660,14 @@ NAME
|
|
660
660
|
|
661
661
|
SYNOPSIS
|
662
662
|
|
663
|
-
na [global options] undo [FILE]...
|
663
|
+
na [global options] undo [command options] [FILE]...
|
664
664
|
|
665
665
|
DESCRIPTION
|
666
666
|
Run without argument to undo most recent change
|
667
667
|
|
668
|
+
COMMAND OPTIONS
|
669
|
+
-s, --[no-]select, --[no-]choose - Select from available undo files
|
670
|
+
|
668
671
|
EXAMPLES
|
669
672
|
|
670
673
|
# Undo the last change
|
data/Test.todo.markdown
CHANGED
@@ -3,19 +3,31 @@ comment: 2023-09-03
|
|
3
3
|
keywords:
|
4
4
|
---
|
5
5
|
|
6
|
-
|
7
|
-
Project2:
|
8
|
-
- new_task @na
|
9
|
-
- new_task @na
|
6
|
+
Project3:
|
10
7
|
Project0:
|
11
|
-
-
|
12
|
-
-
|
13
|
-
-
|
8
|
+
- This is another task @na
|
9
|
+
- How about this one? @na
|
10
|
+
- what happens now? @na
|
14
11
|
Subproject:
|
15
|
-
-
|
12
|
+
- Bollocks @na
|
13
|
+
Subsub:
|
14
|
+
- Hey, I think it's all working @na
|
15
|
+
- Is this at the end? @na
|
16
|
+
- This better work @na
|
17
|
+
2023-09-08:
|
18
|
+
Project2:
|
19
|
+
- new_task @na
|
16
20
|
- new_task @na
|
17
|
-
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
21
|
+
- test task @na
|
22
|
+
Project0:
|
23
|
+
- other task @na
|
24
|
+
- other task @na
|
25
|
+
- There, that's better @na
|
26
|
+
Subproject:
|
27
|
+
- new_task 2 @na
|
28
|
+
- new_task @na
|
29
|
+
- new_task 2 @na
|
30
|
+
Project1:
|
31
|
+
- Test4
|
32
|
+
- Test5
|
33
|
+
- Test6
|
data/bin/commands/tag.rb
CHANGED
@@ -89,10 +89,6 @@ class App
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
if (tokens.nil? || tokens.empty?) && options[:tagged].empty?
|
93
|
-
NA.notify("#{NA.theme[:error]}Empty input, cancelled", exit_code: 1)
|
94
|
-
end
|
95
|
-
|
96
92
|
all_req = options[:tagged].join(' ') !~ /[+!-]/ && !options[:or]
|
97
93
|
tags = []
|
98
94
|
options[:tagged].join(',').split(/ *, */).each do |arg|
|
data/bin/commands/undo.rb
CHANGED
@@ -6,11 +6,20 @@ class App
|
|
6
6
|
long_desc 'Run without argument to undo most recent change'
|
7
7
|
arg_name 'FILE', optional: true, multiple: true
|
8
8
|
command %i[undo] do |c|
|
9
|
+
c.desc 'Select from available undo files'
|
10
|
+
c.switch %i[s select choose]
|
11
|
+
|
9
12
|
c.example 'na undo', desc: 'Undo the last change'
|
10
13
|
c.example 'na undo myproject', desc: 'Undo the last change to a file matching "myproject"'
|
11
14
|
|
12
15
|
c.action do |_global_options, options, args|
|
13
|
-
if
|
16
|
+
if options[:select]
|
17
|
+
options = IO.read(NA.database_path(file: 'last_modified.txt')).strip.split(/\n/)
|
18
|
+
res = NA.choose_from(options, sorted: false)
|
19
|
+
NA.notify("#{NA.theme[:error]}Cancelled", exit_code: 1) unless res
|
20
|
+
|
21
|
+
NA.restore_modified_file(res)
|
22
|
+
elsif args.empty?
|
14
23
|
NA.restore_last_modified_file
|
15
24
|
else
|
16
25
|
args.each do |arg|
|
data/bin/na
CHANGED
data/lib/na/array.rb
CHANGED
data/lib/na/next_action.rb
CHANGED
@@ -410,7 +410,6 @@ module NA
|
|
410
410
|
parent = project.split(%r{[:/]})
|
411
411
|
|
412
412
|
if NA.global_file
|
413
|
-
puts NA.global_file
|
414
413
|
if NA.cwd_is == :tag
|
415
414
|
add_tag = [NA.cwd]
|
416
415
|
else
|
@@ -622,10 +621,7 @@ module NA
|
|
622
621
|
## @param search The search
|
623
622
|
##
|
624
623
|
def last_modified_file(search: nil)
|
625
|
-
|
626
|
-
return nil unless File.exist?(db)
|
627
|
-
|
628
|
-
files = IO.read(db).split(/\n/).map(&:strip)
|
624
|
+
files = backup_files
|
629
625
|
files.delete_if { |f| f !~ Regexp.new(search.dir_to_rx(require_last: true)) } if search
|
630
626
|
files.last
|
631
627
|
end
|
@@ -644,19 +640,72 @@ module NA
|
|
644
640
|
end
|
645
641
|
end
|
646
642
|
|
643
|
+
##
|
644
|
+
## Get list of backed up files
|
645
|
+
##
|
646
|
+
## @return [Array] list of file paths
|
647
|
+
##
|
648
|
+
def backup_files
|
649
|
+
db = database_path(file: 'last_modified.txt')
|
650
|
+
NA.notify("#{NA.theme[:error]}Backup database not found", exit_code: 1) unless File.exist?(db)
|
651
|
+
|
652
|
+
IO.read(db).strip.split(/\n/).map(&:strip)
|
653
|
+
end
|
654
|
+
|
655
|
+
def move_deprecated_backups
|
656
|
+
backup_files.each do |file|
|
657
|
+
if File.exist?(old_backup_path(file))
|
658
|
+
NA.notify("Moving deprecated backup to new backup folder (#{file})", debug: true)
|
659
|
+
backup_path(file)
|
660
|
+
end
|
661
|
+
end
|
662
|
+
end
|
663
|
+
|
664
|
+
def old_backup_path(file)
|
665
|
+
File.join(File.dirname(file), ".#{File.basename(file)}.bak")
|
666
|
+
end
|
667
|
+
|
668
|
+
##
|
669
|
+
## Get the backup file path for a file
|
670
|
+
##
|
671
|
+
## @param file The file
|
672
|
+
##
|
673
|
+
def backup_path(file)
|
674
|
+
backup_home = File.expand_path('~/.local/share/na/backup')
|
675
|
+
backup = old_backup_path(file)
|
676
|
+
backup_dir = File.join(backup_home, File.dirname(backup))
|
677
|
+
FileUtils.mkdir_p(backup_dir) unless File.directory?(backup_dir)
|
678
|
+
|
679
|
+
backup_target = File.join(backup_home, backup)
|
680
|
+
FileUtils.mv(backup, backup_target) if File.exist?(backup)
|
681
|
+
backup_target
|
682
|
+
end
|
683
|
+
|
684
|
+
def weed_modified_files(file = nil)
|
685
|
+
files = backup_files
|
686
|
+
|
687
|
+
files.delete_if { |f| f =~ /#{file}/ } if file
|
688
|
+
|
689
|
+
files.delete_if { |f| !File.exist?(backup_path(f)) }
|
690
|
+
|
691
|
+
File.open(database_path(file: 'last_modified.txt'), 'w') { |f| f.puts files.join("\n") }
|
692
|
+
end
|
693
|
+
|
647
694
|
##
|
648
695
|
## Restore a file from backup
|
649
696
|
##
|
650
697
|
## @param file The file
|
651
698
|
##
|
652
699
|
def restore_modified_file(file)
|
653
|
-
bak_file =
|
700
|
+
bak_file = backup_path(file)
|
654
701
|
if File.exist?(bak_file)
|
655
702
|
FileUtils.mv(bak_file, file)
|
656
703
|
NA.notify("#{NA.theme[:success]}Backup restored for #{file.highlight_filename}")
|
657
704
|
else
|
658
705
|
NA.notify("#{NA.theme[:error]}Backup file for #{file.highlight_filename} not found")
|
659
706
|
end
|
707
|
+
|
708
|
+
weed_modified_files(file)
|
660
709
|
end
|
661
710
|
|
662
711
|
##
|
@@ -821,11 +870,9 @@ module NA
|
|
821
870
|
## @param target [String] The file to back up
|
822
871
|
##
|
823
872
|
def backup_file(target)
|
824
|
-
|
825
|
-
backup = File.join(File.dirname(target), file)
|
826
|
-
FileUtils.cp(target, backup)
|
873
|
+
FileUtils.cp(target, backup_path(target))
|
827
874
|
save_modified_file(target)
|
828
|
-
NA.notify("#{NA.theme[:warning]}Backup file created
|
875
|
+
NA.notify("#{NA.theme[:warning]}Backup file created for #{target.highlight_filename}", debug: true)
|
829
876
|
end
|
830
877
|
|
831
878
|
##
|
data/lib/na/string.rb
CHANGED
@@ -52,7 +52,7 @@ class ::String
|
|
52
52
|
prefix = match(/(^[ \t]+)/)
|
53
53
|
return 0 if prefix.nil?
|
54
54
|
|
55
|
-
prefix[1].gsub(/
|
55
|
+
prefix[1].gsub(/ /, "\t").scan(/\t/).count
|
56
56
|
end
|
57
57
|
|
58
58
|
def action?
|
@@ -149,6 +149,8 @@ class ::String
|
|
149
149
|
end
|
150
150
|
|
151
151
|
def wrap(width, indent)
|
152
|
+
return "\n#{self}" if width < 60
|
153
|
+
|
152
154
|
output = []
|
153
155
|
line = []
|
154
156
|
length = indent
|
data/lib/na/version.rb
CHANGED
data/src/_README.md
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
_If you're one of the rare people like me who find this useful, feel free to
|
10
10
|
[buy me some coffee][donate]._
|
11
11
|
|
12
|
-
The current version of `na` is <!--VER-->1.2.
|
12
|
+
The current version of `na` is <!--VER-->1.2.53<!--END VER-->.
|
13
13
|
|
14
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
15
|
|
data/test2.txt
ADDED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: na
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.54
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brett Terpstra
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -247,6 +247,7 @@ files:
|
|
247
247
|
- na.rdoc
|
248
248
|
- scripts/fixreadme.rb
|
249
249
|
- src/_README.md
|
250
|
+
- test2.txt
|
250
251
|
homepage: https://brettterpstra.com/projects/na/
|
251
252
|
licenses:
|
252
253
|
- MIT
|