oktags 0.2.1 → 0.2.2
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.
- checksums.yaml +4 -4
- data/Gemfile +5 -3
- data/Gemfile.lock +2 -0
- data/README.org +64 -50
- data/bin/oktags +1 -1
- data/lib/hash.rb +15 -0
- data/lib/ok/tags.rb +4 -22
- data/lib/ok/version.rb +1 -1
- 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: 627114b53a234963a6e1547602f9bdabbd2e91814b6d7b07de8d2f07989170c4
|
4
|
+
data.tar.gz: 16fe1866c9793190c90af178b5125685b4afd4645cb2e43574c952466408bb5b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d85747e3fd8ccad82fa328a853a3aea67e4ae6d2116474e34f61599fe535624f89ba8d540e296a847e652b5273bbcb60e95c340d236039ac4124a9d79b0bf983
|
7
|
+
data.tar.gz: 5d606c25adf29ace1025ce67a2287f4078775254c3dba57768dcdfc8e79a5390abdddd8976e3c4d6a37f45dd60e417271d9a3093a2db6d4dfbabe5812cc18530
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.org
CHANGED
@@ -18,13 +18,15 @@
|
|
18
18
|
|
19
19
|
#+begin_example
|
20
20
|
Usage: oktags [options]
|
21
|
-
-l, --list [PATH] List file tags (optionally for PATH)
|
22
21
|
-a, --add-tags TAGS FILE Add comma-separated TAGS to FILE
|
22
|
+
-d TAG FILE, Delete TAG from FILE
|
23
|
+
--delete-tag-from-file
|
23
24
|
-i FILE, Auto-complete tags and add them to FILE
|
24
25
|
--add-tags-interactively
|
26
|
+
-l, --list [PATH] List file tags (optional PATH)
|
25
27
|
-r, --rename-tag OLD_TAG NEW_TAG Rename OLD_TAG to NEW_TAG(S) recursively for all files
|
26
|
-
-
|
27
|
-
--
|
28
|
+
-s TAGS [PATH], Search files which include (comma-separated) tags recursively (optional PATH)
|
29
|
+
--search-files-with-tags
|
28
30
|
#+end_example
|
29
31
|
|
30
32
|
* DESCRIPTION
|
@@ -37,34 +39,32 @@ it should work on Linux, macOS and Windows.
|
|
37
39
|
|
38
40
|
* EXAMPLES
|
39
41
|
|
40
|
-
|
41
|
-
|
42
|
-
#+begin_example
|
43
|
-
$ touch foo
|
44
|
-
$ touch bar.txt
|
45
|
-
$ touch foobar--[tag1,tag2].pdf
|
46
|
-
$ touch baz--[tag1].txt
|
47
|
-
$ oktags -l
|
48
|
-
tag1(2)
|
49
|
-
tag2(1)
|
50
|
-
#+end_example
|
51
|
-
|
52
|
-
Listing all tags for a given path glob (assuming the same data set as above).
|
42
|
+
Add tags to a file. Tags are always unique.
|
53
43
|
|
54
44
|
#+begin_example
|
55
|
-
$
|
56
|
-
tag1
|
45
|
+
$ touch foobar
|
46
|
+
$ oktags -a tag1 foobar
|
47
|
+
$ ls foobar*
|
48
|
+
foobar--[tag1]
|
49
|
+
$ oktags -a tag2 foobar--\[tag1\]
|
50
|
+
$ ls foobar*
|
51
|
+
foobar--[tag1,tag2]
|
52
|
+
$ oktags -a tag3,tag2 foobar--[tag1,tag2].pdf
|
53
|
+
$ ls foobar*
|
54
|
+
foobar--[tag1,tag2,tag3].pdf
|
57
55
|
#+end_example
|
58
56
|
|
59
|
-
|
57
|
+
Delete a tag from a file.
|
60
58
|
|
61
59
|
#+begin_example
|
62
|
-
|
63
|
-
|
64
|
-
|
60
|
+
$ find . | grep business_card | head -n 1
|
61
|
+
./archiv/Reto_Huber--[business_card,somedia,seo].pdf
|
62
|
+
$ oktags -d seo ./archiv/Reto_Huber--[business_card,somedia,seo].pdf
|
63
|
+
$ find . | grep business_card | head -n 1
|
64
|
+
./archiv/Reto_Huber--[business_card,somedia].pdf
|
65
65
|
#+end_example
|
66
66
|
|
67
|
-
Interactively
|
67
|
+
Interactively add tags (with auto-completion through readline) to a file.
|
68
68
|
|
69
69
|
#+begin_example
|
70
70
|
$ oktags -i foo
|
@@ -72,30 +72,50 @@ Interactively adding tags (with auto-completion through readline) to a file.
|
|
72
72
|
tag1 tag2 tag3
|
73
73
|
> tag2, new tag
|
74
74
|
$ ls foo* | grep new
|
75
|
-
foo--[
|
75
|
+
foo--[new_tag,tag2]
|
76
|
+
#+end_example
|
77
|
+
|
78
|
+
List all tags in the current folder.
|
79
|
+
|
80
|
+
#+begin_example
|
81
|
+
$ touch foo
|
82
|
+
$ touch bar.txt
|
83
|
+
$ touch foobar--[tag1,tag2].pdf
|
84
|
+
$ touch baz--[tag1].txt
|
85
|
+
$ oktags -l
|
86
|
+
tag1(2)
|
87
|
+
tag2(1)
|
88
|
+
#+end_example
|
89
|
+
|
90
|
+
List all tags for a given path glob (assuming the same data set as above).
|
91
|
+
|
92
|
+
#+begin_example
|
93
|
+
$ oktags -l '*txt'
|
94
|
+
tag1(1)
|
76
95
|
#+end_example
|
77
96
|
|
78
|
-
|
97
|
+
Rename tag.
|
79
98
|
|
80
99
|
#+begin_example
|
81
100
|
$ oktags -l
|
82
101
|
200ok_expense(8)
|
83
102
|
business_card(4)
|
84
|
-
$ oktags -r 200ok_expense
|
103
|
+
$ oktags -r 200ok_expense 200ok,expense
|
85
104
|
$ oktags -l
|
86
105
|
expense(8)
|
87
106
|
200ok(8)
|
88
107
|
business_card(4)
|
89
108
|
#+end_example
|
90
109
|
|
91
|
-
|
110
|
+
Search files with tags.
|
92
111
|
|
93
112
|
#+begin_example
|
94
|
-
$
|
95
|
-
|
96
|
-
|
97
|
-
$
|
98
|
-
|
113
|
+
$ oktags -s somedia,seo,business_card
|
114
|
+
archiv/Reto_Huber--[business_card,seo,somedia].pdf
|
115
|
+
archiv/Reto_Huber--[business_card,seo,somedia].txt
|
116
|
+
$ oktags -s business_card '**/*pdf'
|
117
|
+
archiv/Reto_Huber--[business_card,seo,somedia].pdf
|
118
|
+
archiv/Stefan_Schmidt--[business_card,lawoon].pdf
|
99
119
|
#+end_example
|
100
120
|
|
101
121
|
* INSTALLATION
|
@@ -122,20 +142,14 @@ the =.gem= file to [[https://rubygems.org][rubygems.org]].
|
|
122
142
|
|
123
143
|
* TESTS
|
124
144
|
|
125
|
-
|
126
|
-
|
127
|
-
#+begin_src shell
|
128
|
-
......
|
129
|
-
|
130
|
-
Finished in 0.00408 seconds (files took 0.07109 seconds to load)
|
131
|
-
6 examples, 0 failures
|
132
|
-
#+end_src
|
145
|
+
Tests are implemented with [[https://rspec.info/][RSpec]] and can be run with =bundle exec
|
146
|
+
rspec spec=.
|
133
147
|
|
134
148
|
* NOTES
|
135
149
|
|
136
150
|
Software systems come and go. It is easy to lose important data in
|
137
|
-
(proprietary) legacy systems. Plain old files are boring and
|
138
|
-
|
151
|
+
(proprietary) legacy systems. Plain old files are boring and are
|
152
|
+
therefore here to stay; at least they [[https://en.wikipedia.org/wiki/Computer_file#Storage][have been around since 1961]].
|
139
153
|
Additional benefits of using plain old files are:
|
140
154
|
|
141
155
|
- They are (mostly) platform independent.
|
@@ -146,14 +160,14 @@ Additional benefits of using plain old files are:
|
|
146
160
|
- They can be transported independently from the software that captured/created them.
|
147
161
|
- They are not proprietary.
|
148
162
|
|
149
|
-
=oktags= is decidedly built to be just as boring as plain old
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
163
|
+
=oktags= is decidedly built to be just as boring as plain old files.
|
164
|
+
It's written in a language that's been proven for shell scripts ([[https://www.ruby-lang.org/en/][Ruby]])
|
165
|
+
rather than using something more 'cool'/'interesting'. It also only
|
166
|
+
uses Ruby built-ins and has no dependencies when run as a CLI or
|
167
|
+
library. =oktags= is therefore boring and here to stay. The idea is to
|
168
|
+
tag your files once and for all, so you will not loose your important
|
169
|
+
data in something that will become an unsupported legacy system at
|
170
|
+
some point.
|
157
171
|
|
158
172
|
At [[https://200ok.ch/][200ok]], we develop various Free Software projects that work on plain
|
159
173
|
old files:
|
data/bin/oktags
CHANGED
data/lib/hash.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
class Hash
|
2
|
+
# like invert but not lossy. possibly a good blog post.
|
3
|
+
def safe_invert
|
4
|
+
inject({}) do |acc, (k, v)|
|
5
|
+
if v.is_a? Array
|
6
|
+
v.each do |vx|
|
7
|
+
acc[vx] = acc[vx].nil? ? k : [acc[vx], k].flatten
|
8
|
+
end
|
9
|
+
else
|
10
|
+
acc[v] = acc[v].nil? ? k : [acc[v], k].flatten
|
11
|
+
end
|
12
|
+
acc
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/ok/tags.rb
CHANGED
@@ -5,25 +5,7 @@ require 'optparse'
|
|
5
5
|
require 'set'
|
6
6
|
require 'readline'
|
7
7
|
require 'fileutils'
|
8
|
-
require
|
9
|
-
|
10
|
-
# TODO: Put this into it's own file
|
11
|
-
class Hash
|
12
|
-
# like invert but not lossy. possibly a good blog post.
|
13
|
-
def safe_invert
|
14
|
-
inject({}) do |acc, (k, v)|
|
15
|
-
if v.is_a? Array
|
16
|
-
v.each do |vx|
|
17
|
-
acc[vx] = acc[vx].nil? ? k : [acc[vx], k].flatten
|
18
|
-
end
|
19
|
-
else
|
20
|
-
acc[v] = acc[v].nil? ? k : [acc[v], k].flatten
|
21
|
-
end
|
22
|
-
acc
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
8
|
+
require File.expand_path(File.join(%w[.. .. hash]), __FILE__)
|
27
9
|
|
28
10
|
module OK
|
29
11
|
module Tags
|
@@ -204,7 +186,7 @@ module OK
|
|
204
186
|
opts.on(
|
205
187
|
'-l',
|
206
188
|
'--list [PATH]',
|
207
|
-
'List file tags (optional PATH)'
|
189
|
+
'List file tags recursively (at optional PATH)'
|
208
190
|
) do |path|
|
209
191
|
path ? list_pretty_tags(path) : list_pretty_tags
|
210
192
|
exit
|
@@ -220,7 +202,7 @@ module OK
|
|
220
202
|
opts.on(
|
221
203
|
'-s',
|
222
204
|
'--search-files-with-tags TAGS [PATH]',
|
223
|
-
'Search files which include (comma-separated)
|
205
|
+
'Search files which include (comma-separated) TAGS recursively (at optional PATH)'
|
224
206
|
) do |tags|
|
225
207
|
if ARGV[0]
|
226
208
|
list_files_with_tags(tags, ARGV[0])
|
@@ -234,4 +216,4 @@ module OK
|
|
234
216
|
end
|
235
217
|
end
|
236
218
|
|
237
|
-
OK::Tags.main
|
219
|
+
OK::Tags.main if $0 == __FILE__
|
data/lib/ok/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oktags
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alain M. Lafon
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: 'oktags helps you organize your files by managing tags on them. It works
|
14
14
|
by adding/removing at the end of the filename. Given a file ''cat.jpg'', when adding
|
@@ -33,6 +33,7 @@ files:
|
|
33
33
|
- bin/console
|
34
34
|
- bin/oktags
|
35
35
|
- bin/setup
|
36
|
+
- lib/hash.rb
|
36
37
|
- lib/ok/tags.rb
|
37
38
|
- lib/ok/version.rb
|
38
39
|
- lib/oktags.rb
|