Skip to content

Commit 2d9a8aa

Browse files
committed
restore original tag-only feats
1 parent d28b0ad commit 2d9a8aa

File tree

7 files changed

+15
-150
lines changed

7 files changed

+15
-150
lines changed

src/app/memos.nim

-33
This file was deleted.

src/app/queries.nim

+4-15
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ from regex import re2, findAll
44
from std/strutils import toLower, isEmptyOrWhitespace, replace, join
55

66
from ../data/tags import readFiles
7-
from ../data/memos import readMemos
87

98
type
109
NodeKind = enum
@@ -69,23 +68,13 @@ func interpret(ast: Node): (HashSet[string] -> bool) =
6968
of nkExtension: "ext[" & ast.val & "]" in tags
7069
of nkType: "type[" & ast.val.toLower & "]" in tags
7170

72-
proc find*(query: string, files, memos: bool) =
73-
# TODO: FIX VISUALIZATION AND ADD QUIET MODE
74-
# ALSO, REMOVE PATHS FROM MEMOS AND ONLY SHOW IN QUIET
71+
proc find*(query: string) =
7572
let
7673
predicate =
7774
if query.isEmptyOrWhitespace or query == "nil":
7875
proc (x: HashSet[string]): bool = true
7976
else: interpret parse query
77+
shownFiles = readFiles(predicate).join("\n")
8078

81-
if files or not (files or memos):
82-
let shownFiles = readFiles(predicate).join("\n")
83-
if shownFiles.len > 0:
84-
echo "FILES:"
85-
echo shownFiles
86-
87-
if memos or not (files or memos):
88-
let shownMemos = readMemos(predicate).join("\n")
89-
if shownMemos.len > 0:
90-
echo "MEMOS:"
91-
echo shownMemos
79+
if shownFiles.len > 0: echo shownFiles
80+

src/data/db.nim

+2-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ type
1313
File* = ref object of Model
1414
path* {.uniqueIndex: "File_paths".}: string
1515
persistent*: bool
16-
memo*: bool
1716

1817
Tag* = ref object of Model
1918
name* {.uniqueIndex: "Tag_names".}: string
@@ -25,8 +24,8 @@ type
2524
tag* {.index: "FileTag_tag".}: Tag
2625
at*: DateTime
2726

28-
func newFile*(path = "", persistent = false, memo = false): File =
29-
File(path: path, persistent: persistent, memo: memo)
27+
func newFile*(path = "", persistent = false): File =
28+
File(path: path, persistent: persistent)
3029

3130
func newTag*(name = "", system = false, desc = ""): Tag =
3231
Tag(name: name, system: system, desc: desc)

src/data/memos.nim

-69
This file was deleted.

src/data/repository.nim

-9
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from std/times import now
2-
from std/hashes import hash
31
from std/os import getDataDir, removeDir, fileExists,
42
existsOrCreateDir, joinPath
53

@@ -8,18 +6,11 @@ const MindHomeDir = ".mind"
86
let
97
mindDataDir = getDataDir().joinPath(MindHomeDir)
108
mindFilesDir = mindDataDir.joinPath("files")
11-
mindMemosDir = mindDataDir.joinPath("memos")
129
mindDbFile* = mindDataDir.joinPath("data.db")
1310

1411
proc existsOrInitRepo*() =
1512
discard existsOrCreateDir mindDataDir
1613
discard existsOrCreateDir mindFilesDir
17-
discard existsOrCreateDir mindMemosDir
1814

1915
proc dropRepo*() = removeDir mindDataDir
2016
proc hardFile*(filename: string): string = mindFilesDir.joinPath(filename)
21-
proc newMemoFile*(): string = mindMemosDir.joinPath("M" & $hash($now()) & ".mem")
22-
proc memoFile*(memoname: string): string =
23-
let memofilepath = mindMemosDir.joinPath(memoname & ".mem")
24-
if memofilepath.fileExists: memofilepath
25-
else: raise newException(ValueError, "Memo '" & memoname & "' not found in store.")

src/data/tags.nim

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ proc readFiles*(predicate: HashSet[string] -> bool): seq[string] =
2929
var
3030
tagds = @[newFileTag()]
3131
tagsByFile: Table[string, HashSet[string]]
32-
withMindDb: db.transaction: db.select(tagds, "File.memo = 0")
32+
withMindDb: db.transaction: db.selectAll tagds
3333

3434
for filetag in tagds:
3535
if not (filetag.file.path in tagsByFile):

src/mind.nim

+8-20
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import docopt
22
import docopt/dispatch
33

4-
import ./app/[memos, tags, queries]
4+
import ./app/[tags, queries]
55
from ./data/db import existsOrInitDb, syncDb
66
from ./data/repository import existsOrInitRepo, dropRepo
77

@@ -17,23 +17,13 @@ Usage:
1717
mind -v
1818
mind sync
1919
mind init [-r]
20-
mind find [-fmq] [<query>]
21-
mind tags ls [-asq] [<tagpattern>]
22-
mind tags tag [-H] <filepattern> <tags>...
23-
mind tags untag <filepattern> [<tags>...]
24-
mind tags mv <name> <newname>
25-
mind tags desc <tag> <description>
26-
mind tags rm <tags>...
27-
mind memos open [<memoid>]
28-
mind memos rm <memos>...
29-
mind tasks new <task>
30-
mind tasks new --from <memoid>
31-
mind tasks done <memoid>
32-
mind tasks undo <memoid>
33-
mind kv store <key> <value>
34-
mind kv get <key>
35-
mind kv rm <key>
36-
mind kv mv <key> <newkey>
20+
mind find [<query>]
21+
mind ls [-asq] [<tagpattern>]
22+
mind tag [-H] <filepattern> <tags>...
23+
mind untag <filepattern> [<tags>...]
24+
mind mv <name> <newname>
25+
mind desc <tag> <description>
26+
mind rm <tags>...
3727
3828
Options:
3929
-h --help Show this screen.
@@ -44,7 +34,6 @@ Options:
4434
-q --quiet Show a shorter more concise version of the output.
4535
-H --hard Create a hard link for a file and tag it.
4636
-f --files Show only files out of the query results.
47-
-m --memos Show only memos out of the query results.
4837
"""
4938

5039
when isMainModule:
@@ -62,5 +51,4 @@ when isMainModule:
6251
args.dispatchProc(modTag, "mv")
6352
args.dispatchProc(describeTag, "desc")
6453
args.dispatchProc(removeTag, "rm")
65-
args.dispatchProc(memo, "memo")
6654
args.dispatchProc(find, "find")

0 commit comments

Comments
 (0)